hgm wrote:The palette is such that each pair of consecutive bits specifies a primary color, at 0, 33%, 67% or 100% intensity. The two lowest bits are for red. (And I suppose the next two bits green, but I ever actually verivied that with Marcel.) There are simply resistors R and 2R conecting the output bits with the VGA pin for that color, to make a 2-bit DAC.
The sound comes from the XOUT port, which is clocked by a SYNC bit of the OUT port. For the rest I think it is purely a software matter; the interpreter would send new output to XOUT every HSYNC pulse (so at 31kHz). I have no idea how it decides what to send.
The input is complex. It seems to be a shift register, clocked by the HSYNC output of the video OUT port. It seems that game controllers are such serial devices, and need to receive a parallel-load signal to get their button states in their shift register. This parallel-load signal is sent to them from the VSYNC pulse. So 8 scan lines after the (end of?) VSYNC the full button info would be readable from IN. No idea how the bits are assigned to buttons.
Thanks, I already figured out that it's probably RGB222 and indeed, it seems to work.
So simply iterating 4 times and doing this: ch = ch | (ch << 2) | (ch << 4) | (ch << 6) seems to do the trick to map to the 0..255 range.
Again a nice and simple solution from Marcel.
I've no idea how to access XOUT though as the original emulator only has OUT register (and no idea how the sample is encoded as it should have 4 channels from what I've read).
2 bits per channel don't seem enough I think, but even if it's only 2 bits per channel, one could use all 4 to generate a single 12 level output:
3 + 3 + 3 + 3 = 12
3 + 3 + 3 + 2 = 11 and so on
I've also noticed Gigatron has 4 LEDs that can be probably controlled by the program as well, so emulating those would be nice also. I guess I'll have to wait to get more information on how exactly the audio, controller and LEDs work.
In the meantime I'll try to prepare and upload this unofficial emulator, in case someone would be interested to try it.