AgonConsole8 / agon-vdp

Official Firmware for the Agon Console8: ESP32 VDP
MIT License
43 stars 17 forks source link

Copper style palette changing #259

Open stevesims opened 4 days ago

stevesims commented 4 days ago

On an Amiga you could program the "Copper" part of Agnus chip to change the palette during render-out.

This had two common uses - firstly "HAM" (Hold And Modify) style screen modes, which could allow for a 16 colour screen mode to display all 4096 colours an Amiga was capable of outputting.

The second common use was to produce "raster bars" or "copper bars", which was an effect that was very commonly seen in demos.

(Copper was actually a co-processor that could run very simple programs that could adjust values in the video output hardware registers. It ran very simple programs that supported just 3 types of instruction - "move", "wait" and "skip". The nature of vdp-gl is that it is probably not worth attempting to replicate this level of functionality - we probably wouldn't have the ability to change anything besides palette entries anyway.)

stevesims commented 4 days ago

Thoughts written about this on Discord:

for HAM-style use, i guess you'd need a buffer that has contains per-row palette info. to save memory, this could be done in a format of having a "line count" followed by the palette, thus allowing multiple lines that share the same palette to be simply compressed.

each new frame, you'd go back to the start of the palette buffer. the last row of data would just "stick" - unless there's more data than rows, in which case the extra rows would be ignored.

raster-bars style effects would probably use a similar arrangement - with the addition of a "wait for next frame" style "command" in the data stream, and wouldn't reset the palette buffer position. maybe having commands to "wait for row", and "use default palette" would also be useful

further to these thoughts - the primary concern really is that commands need to be super-simplistic; changing individual palette entries would likely be too slow - changing the palette wholesale is a "change a pointer" operation and thus practical.

perhaps we could have a "set alternate palette" command, and then these copper-style palette lists would just be a "line count" followed by a "palette index".