Interrupt driven video

A project log for Tjipp8 - A Chip-8 game console

A low part count PIC16F1705 game console for the ancient (1970's) Chip-8 bytecode interpreters originally run at the Cosmac 1802.

matsengmatseng 01/19/2017 at 11:205 Comments

Ok... Spent an hour or two rewriting most of the code today to use interrupts at 64us intervals instead of having precise timed loops.

The code ended up about the same size but is now easier to maintain and it makes it possible to run an application software in the foreground without disturbing the video that is in the background handled by the interrupts.

About 2/3'rds of the CPU time is spent inside the interrupt handler doing video & sync outputs. The remaining 1/3'rd is available for the foreground application/game. That should be plenty for a Chip-8 interpreter to run at full original speed.

The output is still a little bit glitchy since I haven't yet been able to de-jitter the interrupt handler, but for the time being it just adds to the 1970's retro feeling :-)


Ted Yapo wrote 01/19/2017 at 15:42 point

I wonder if there is a way to make a composite display with 16x9 aspect ratio that will have square pixels on a 16x9 monitor in "streched" mode.  Your pixels actually look kinda sqaure - is it just that 64:32 is close to 16:9?

I guess true 16:9 would be 64x36.  I wonder if that would be possible.  The vertical is no longer a nice power of two, but still ... 

Oh, I see that Chip-8 specifies 64x32.

  Are you sure? yes | no

matseng wrote 01/19/2017 at 16:16 point

By some incredible luck they ended up quite square on 16:9 using seven lines vertically and five instruction cycles (625 ns) horizontally. Using 8 lines per pixel and I'm outside of the PAL display area, and with 6 cycles horizontally I also end up outside of the display area.

The loop-unrolled video-output code have 3 cycle extra delay for each pixel, removing them I could squeeze in 208 pixels horizontally with bitbanging  only - not using the SPI or EUSART peripherals.

The dox says that the pixels was about square also on the 4:3 back in the days. This implies that they used much wider left/right empty margins on the screen for chip8 back then....

  Are you sure? yes | no

Ted Yapo wrote 01/19/2017 at 14:10 point

Nice video wrencher!

  Are you sure? yes | no

matseng wrote 01/19/2017 at 14:53 point

Yup...  64*32 should be enough for anyone - or anything ;-

  Are you sure? yes | no

Ted Yapo wrote 01/19/2017 at 22:37 point

It makes me want a 64x32 LED display...

  Are you sure? yes | no