element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
element14 presents
  • Challenges & Projects
  • More
element14 presents
e14 presents blogs Converting Apple II video bitstream into HDMI (with an RP2040?)
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join element14 presents to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: baldengineer
  • Date Created: 9 Jan 2022 7:38 PM Date Created
  • Views 7199 views
  • Likes 11 likes
  • Comments 4 comments
  • mini iie
  • retro computer
  • rp2040
  • pi pico
Related
Recommended

Converting Apple II video bitstream into HDMI (with an RP2040?)

baldengineer
baldengineer
9 Jan 2022
Converting Apple II video bitstream into HDMI (with an RP2040?)

In the Mini IIe project, I need video output. The Rev 1 shown in the project video relied on the analog video circuit from the IIgs. So I copied and pasted it from the IIgs schematic. (Well, in KiCad 5, you had to copy the file and then edit the schematic to remove what you did not want. But ... the same idea.) The positive to this approach is that I had a ready-to-go circuit. The downside is that it is still wholly analog AND not compatible with all digital capture devices.

Apple II Video

Apple II video block diagramCamera: "The Apple II Circuit Description" by W. Gayler

Apple II video is famous, or infamous, for how Steve Wozniak designed it. The block diagram above is from a book on the original Apple II. The fundamental video system is the same in all Apple IIs, except the IIgs. Adding 80 column support changes some memory areas, but the other modes are the same. The video generator circuit is the logic that creates a digital video bitstream. In that block diagram, it is labeled "Video Data" while the Mega-II (and IIe) call the same signal SERVID.

NTSC Color (Brief Primer)

image

(Camera: Video Levels from NI)

In NTSC video, there is a sync pulse for the start of a frame, a voltage level to set black, a voltage level to set white, and then luminance (brightness) information. For a black and white display, you can use a waveform that is either ON or OFF in that area to make dots appear on a TV screen (or monitor.) If a 3.58 MHz signal, called Color Burst, is added before the black level, the receiver knows the rest of the waveform contains color information. In addition, the luminance now includes a modulated signal on analog video generators where the modulation's phase difference from the Color Burst adds chrominance (Color) information. This clever "hack" is how color could co-exist on the already widely used "B&W" standard. And it worked great from the 1960s until the early 2000s when broadcasters phased out analog TV.

image

Camera: "The Apple II Circuit Description" by W. Gayler

However, it created a potential problem for digital computers like the Apple II. Wozniak didn't design an analog system or add another oscillator to generate the chrominance. Instead, the Apple II's all digital video generator uses a shift register in the video generation block to shift the "luma" signal's phase, causing a dot to change color. Since color is phase-related, the receiver cannot always distinguish between two luminance "points." So, depending on the colors picked you might either end up with a big white dot or a slight rainbow effect as the receiver struggles to interpret the all-digital waveform. (The behavior also depends on which video mode the Apple II is operating in.)

In the original Apple IIe and the Mega-II, there is a digital signal called "Serial Video" or SERVID. The video has a bitstream of luminance information, with the appropriate phase shifts. Combining that signal with a sync pulse and color burst creates an "analog" composite video signal with color.

Mega-II's SERVID Signals

Since I do not want an analog output, we need to find a way to convert the digital bitstream of the Mega-II into a modern digital video signal. The Mega-II outputs a handful of video-related signals. There are four RGBx signals, which might seem like one too many. However, they are not discrete color channels! Instead, they are a slower parallel copy of SERVID.

The IIgs's VGC uses those four RGBx signals, the system clocks, and Mega-II's SYNC horizontal SYNC signal to create 12-bit binary red, green, and blue values. The rest of the video circuit converts those digital values into analog and adds color burst information when the video mode requires it. The VGC also creates a vertical blanking signal.

imageCamera: Top waveform is composite analog, and the bottom is digital creating it


After extensive measurements with an Analog Discovery Pro, we determined that it should be possible for us to take in the SERVID signal, SYNC, and either the 7 MHz or 14 MHz clocks to build video frames line-by-line.

The question is, then what do we do next? Well, we frame buffer the signal with a microcontroller. Since getting this signal in at a few MHz will be time-critical, it looks like another use-case for the RP2040, which means there are three options to consider: VGA, USB, or HDMI.

VGA

Andy's Game Guy video shares some commonalities with the Mini IIe project. It is re-packing retro technology into a different form factor while using the Pi Pico (or RP2040) as glue. The main difference is that he made his project physically bigger, and I am making mine smaller! His project takes analog video and converts it into VGA, which uses an RP2040. Then for HDMI, he's using a no-name VGA to HDMI adapter. For the Mini IIe, I want a more integrated solution, so while this is an optional path, I'd rather consider it a backup plan.

USB

Regardless of the option we use, they will require using a frame buffer. Fortunately, the tinyUSB library already has support for Video and Audio devices. So it would be possible just to put a micro-USB port on the back, plug it into a computer, and use something like OBS or VLC to "capture" the output. The primary benefit here is that it uses very little extra hardware. The downside is that it requires a PC to be useful.

HDMI

I like the idea of using USB for testing (and streaming.) However, in my latest vision for the Mini IIe project, I want to connect it to an HDMI-capable monitor (or TV). So for HDMI, I think we will use an ITE Tech 6613. It's an HDMI transmitter that can take in digital RGB (or luminance) signals that output to HDMI. It is the same chip used in the Open Source Scan Converter project. Getting the chip is another story. (And is for another time.) We will likely have to rely on something like the OSSC project's code on how to control it since I do not have an NDA for the (whole) datasheet.

But, that is getting a little too far ahead.

What about the RP2040's DVI Sock?

People have pointed me to one project called the "DVI Sock." It's a combination of hardware and RP2040 PIO code that outputs a DVI-compatible signal from the RP2040. While this benefits from creating a signal that HDMI receivers can use, it is missing one key feature: audio. There's no well-established method for getting audio and DVI into an HDMI TV.

If you know of one, let me know below!

(Current) Video Plan

My video plan uses an RP2040 to ingest the SERVID and SYNC signals from the Mega-II, buffer it in RAM, and then output via USB. (Andy's latest video has me thinking this is the right direction.) I have already fabricated an RP2040 to HDMI PCB for testing. The primary goal with this board is to test the ITE 6613's modes and registers.

My thinking is that since the bitstream is well defined, we should be able to reconstruct the analog picture from SERVID. My concern is that color artifacts may not survive. Disappointed

With all of that said, I am still open to other ideas! For example, what else should I consider for converting the Apple II video bitstream to something modern?

  • Sign in to reply
Parents
  • lukazi
    lukazi over 3 years ago

    Hi James, Love your work (especially the single-chip Apple II stuff). Interesting idea options you have. I've done a few Apple II video converters. In case it helps this has been my experience.

    USB: I did this many years ago. I used a Cypress EX-USB FX2LP to pass Apple II video via USB to a PC. Worked well but as you said, it requires a PC to output the display.

    RPi Pico / DVI Sock: I did this but would not recommend it. Monochrome worked well but I could not get colour output from the dvi driver working on several TVs/monitors. RPi Pico to VGA sounds like a better way to use the Pico.

    HDMI-1: I used Apple II to RPi Pico as serial to parallel converter / buffer then 8bit data bus to RPi Zero. Zero processes the data on the fly and outputs directly to the HDMI Frame Buffer. Colour was easily added with just a few lines of code. No complex math needed just two lookup tables (palette and 12bit colour relationship). I'm in the process of documenting this up for my blog - lukazi at blogspot dot com.

    HDMI-2: Tang Nano 4K FPGA. Looks promising. I have one on order.

    Looking forward to seeing your solution. Cheers, Alex.   

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • baldengineer
    baldengineer over 3 years ago in reply to lukazi

    Thanks Alex, that is some good feedback.

    I'd be interested in learning more about your HDMI-1 frame buffer idea.

    For now, I've decided to use a second RP2040 to generate VGA. Then I'll provide analog audio out the back. From there, I can use an off-the-shelf VGA-to-HDMI adapter. I've found a really robust VGA library that I think will handle the framebuffering and conversion to VGA's RGB. That leaves me time to focus on decoding the SERVID signals from the Mega-II.

    I want to come back to HDMI later because I have (now) have other ideas for it. But I decided it isin the critical path for reaching my next milestone on this project.

    I made the tough decision to get to the milestone and address HDMI in the future.(and I'll likely be looking at an FPGA solution in that case.)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • baldengineer
    baldengineer over 3 years ago in reply to lukazi

    Thanks Alex, that is some good feedback.

    I'd be interested in learning more about your HDMI-1 frame buffer idea.

    For now, I've decided to use a second RP2040 to generate VGA. Then I'll provide analog audio out the back. From there, I can use an off-the-shelf VGA-to-HDMI adapter. I've found a really robust VGA library that I think will handle the framebuffering and conversion to VGA's RGB. That leaves me time to focus on decoding the SERVID signals from the Mega-II.

    I want to come back to HDMI later because I have (now) have other ideas for it. But I decided it isin the critical path for reaching my next milestone on this project.

    I made the tough decision to get to the milestone and address HDMI in the future.(and I'll likely be looking at an FPGA solution in that case.)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube