AgonConsole8 / agon-vdp

Official Firmware for the Agon Console8: ESP32 VDP
MIT License
38 stars 13 forks source link

Idea: support 32-bit values in expand bitmap command #240

Open stevesims opened 1 month ago

stevesims commented 1 month ago

the current buffered commands API command to expand out a bitmap supports expanding to 8-bit values only - as it was essentially intended to create RGBA2222 format bitmaps

there may be utility in allowing an option to expand to 32-bit values (and thus if used for bitmap graphics to RGBA8888 format)

additionally a mode that can be used to create RGBA8888 format bitmap data directly from RGBA2222 format bitmap data could be useful. this would not need a mapping list of values as they can be created from the source values directly

(thinking about it, a simple way to expand RGBA2222 to RGBA8888 would be to expand 2-bits per pixel...)

stevesims commented 3 weeks ago

experiments showed that it is possible to expand RGBA2222 into RGBA8888, by using the fact that it can be expanded as if an RGBA2222 bitmap is really a 2-bpp "greyscale" image. the byte order of an RGBA8888 image however does not match the bit order of an RGBA2222 image. this can be resolved tho by using a "reverse" command

an example command sequence is as follows:

REM first expand bitmap data into target buffer
VDU 23, 0, &A0, targetId%; &48, 2, sourceId%; 0, &7F, &BF, &FF
REM then reverse bytes to correct order
VDU 23, 0, &A0, targetId%; 24, 4, 4;
REM get the bitmap system to select the target buffer
VDU 23, 27, &20, targetId%;
REM and set that to be an RGBA8888 bitmap
VDU 23, 27, &21, width%; height%; 0

this should be added to the documentation