Video Mode 9: Difference between revisions
mNo edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
==Introduction== | |||
Video mode 9 has the highest resolution on the Uzebox at 4 cycles per pixel yielding 360x224 for 60x28 tiles. This resolution is attained by using "codetiles" where the tile data (or pixels) are actually made of AVR assembly instructions. which embeds both the pixels color and the code to output it. This however comes to the expense of flash usage since 6x8 pixels codetiles consumes 336 bytes of flash vs. 48bytes for regular tiles. | |||
The video mode also supports setting different background colors per tile row. | |||
==Using video mode 9== | |||
To use Mode 9 , configure your Makefile with this parameter: | |||
<source lang="c"> | |||
KERNEL_OPTIONS += -DVIDEO_MODE=9 | |||
</source> | |||
An | |||
u8 backgroundColor[VRAM_TILES_V]; | |||
==Implementation== | |||
The Gconvert tool generates the following assembly code for codetiles. If background color was specified in the gconvert config file, pixels in the input picture matching the bg color would result in the "ldi r16,pixeln" replaced by "mov r16,r2". | |||
<source lang="asm"> | |||
ldi r16, pixel1 ; ?1 e? ; 1 cycle | |||
out 0x08, r16 ; 08 b9 ; 1 cycle | |||
ld r17, Y+ ; 19 91 ; 2 cycles | |||
ldi r16, pixel2 ; ?1 e? ; 1 cycle | |||
out 0x08, r16 ; 08 b9 ; 1 cycle | |||
mul r17, r21 ; 15 9f ; 2 cycles | |||
ldi r16, pixel3 ; ?1 e? ; 1 cycle | |||
out 0x08, r16 ; 08 b9 ; 1 cycle | |||
add r0, r24 ; 08 0e ; 1 cycle | |||
adc r1, r25 ; 19 1e ; 1 cycle | |||
ldi r16, pixel4 ; ?1 e? ; 1 cycle | |||
out 0x08, r16 ; 08 b9 ; 1 cycle | |||
movw r30, r18 ; f9 01 ; 1 cycle | |||
dec r20 ; 4a 95 ; 1 cycle | |||
ldi r16, pixel5 ; ?1 e? ; 1 cycle | |||
out 0x08, r16 ; 08 b9 ; 1 cycle | |||
breq .+2 ; 09 f0 ; 1 cycle or 2 if r20 is 0 | |||
movw r30, r0 ; f0 01 ; 1 cycle | |||
ldi r16, pixel6 ; ?1 e? ; 1 cycle | |||
out 0x08, r16 ; 08 b9 ; 1 cycle | |||
ijmp ; 09 94 ; 2 cycles | |||
</source> | |||
[http://uzebox.org/forums/viewtopic.php?p=5419#p5419 Original Forum thread] | [http://uzebox.org/forums/viewtopic.php?p=5419#p5419 Original Forum thread] |
Revision as of 23:45, 5 June 2013
Introduction
Video mode 9 has the highest resolution on the Uzebox at 4 cycles per pixel yielding 360x224 for 60x28 tiles. This resolution is attained by using "codetiles" where the tile data (or pixels) are actually made of AVR assembly instructions. which embeds both the pixels color and the code to output it. This however comes to the expense of flash usage since 6x8 pixels codetiles consumes 336 bytes of flash vs. 48bytes for regular tiles.
The video mode also supports setting different background colors per tile row.
Using video mode 9
To use Mode 9 , configure your Makefile with this parameter:
KERNEL_OPTIONS += -DVIDEO_MODE=9
An
u8 backgroundColor[VRAM_TILES_V];
Implementation
The Gconvert tool generates the following assembly code for codetiles. If background color was specified in the gconvert config file, pixels in the input picture matching the bg color would result in the "ldi r16,pixeln" replaced by "mov r16,r2".
ldi r16, pixel1 ; ?1 e? ; 1 cycle
out 0x08, r16 ; 08 b9 ; 1 cycle
ld r17, Y+ ; 19 91 ; 2 cycles
ldi r16, pixel2 ; ?1 e? ; 1 cycle
out 0x08, r16 ; 08 b9 ; 1 cycle
mul r17, r21 ; 15 9f ; 2 cycles
ldi r16, pixel3 ; ?1 e? ; 1 cycle
out 0x08, r16 ; 08 b9 ; 1 cycle
add r0, r24 ; 08 0e ; 1 cycle
adc r1, r25 ; 19 1e ; 1 cycle
ldi r16, pixel4 ; ?1 e? ; 1 cycle
out 0x08, r16 ; 08 b9 ; 1 cycle
movw r30, r18 ; f9 01 ; 1 cycle
dec r20 ; 4a 95 ; 1 cycle
ldi r16, pixel5 ; ?1 e? ; 1 cycle
out 0x08, r16 ; 08 b9 ; 1 cycle
breq .+2 ; 09 f0 ; 1 cycle or 2 if r20 is 0
movw r30, r0 ; f0 01 ; 1 cycle
ldi r16, pixel6 ; ?1 e? ; 1 cycle
out 0x08, r16 ; 08 b9 ; 1 cycle
ijmp ; 09 94 ; 2 cycles