-
Notifications
You must be signed in to change notification settings - Fork 6
Description
It is not possible to do 4 bit affine reads in 8 bit video mode.
Basic idea of this feature is to double the texture storage in the same VRAM limit.
Software color lookup code:
ldy VERA_DATA1
lda COLORMAP,y
sta VERA_DATA0
4 bit reads can be combined in software with simple table lookup to create textures with 16 colors out of 256 colors. This also opens a possibility for multiple lookup tables per single texture, allowing extra color variants at the cost of only 16 bytes per variant.
These color variants could also be different shades (light levels). This can also allow fast animations (like flowing water) by using different lookup table every frame.
It is possible to emulate this feature in software. Either at the cost of speed or RAM usage.
- RAM intensive implementation
Using 256 byte lookup table instead of 16 bytes, it is possible to "mask out" upper or lower nibble by duplicating the same color index. But at the cost of 256 bytes per table. That is 16x more more memory per table.
For example, a texture variant with 16 shades require 16 lookup tables, either 256 bytes, with this feature implemented, or 4096 bytes, in current implementation.
- CPU intensive implementation
Using alternative lookup code it is possible to get HI or LO nibble.
lda VERA_DATA1
and #$0F
tay
lda COLORMAP,y
sta VERA_DATA0
HI nibble can be accessed using a table lookup instead of and opcode
Alternative hardware implementation
Instead of implementing 4 bit access in 8 bit mode, allow masking of HI or LO nibble when reading from ADDR1 using affine helper.
I have already consulted this option with Jeffrey and these are proposed changes that would implement this variant of this feature: main...visual-trials:vera-module:nibble_masked_reading
Here is (untested) implementation in emulator by MooingLemur: X16Community/x16-emulator@master...mooinglemur:x16-emulator:20240126-fxnibblewrite
This implementation reuses some unused registers in affine helper and 8 bit mode and achieves very similar outcome - it is still possible to pack two 4bpp textures into a single 8bpp texture.