26 #ifndef _SIFTEO_ABI_VRAM_H
27 #define _SIFTEO_ABI_VRAM_H
29 #include <sifteo/abi/types.h>
49 #define _SYS_VRAM_BYTES 1024
50 #define _SYS_VRAM_BYTE_MASK (_SYS_VRAM_BYTES - 1)
53 #define _SYS_VRAM_WORDS (_SYS_VRAM_BYTES / 2)
54 #define _SYS_VRAM_WORD_MASK (_SYS_VRAM_WORDS - 1)
56 #define _SYS_VRAM_BG0_WIDTH 18 // Width/height of BG0 tile grid
57 #define _SYS_VRAM_BG1_WIDTH 16 // Width/height of BG1 bitmap
58 #define _SYS_VRAM_BG1_TILES 144 // Total number of opaque tiles in BG1
59 #define _SYS_VRAM_BG2_WIDTH 16 // Width/height of BG2 tile grid
60 #define _SYS_VRAM_SPRITES 8 // Total number of linear sprites
61 #define _SYS_SPRITES_PER_LINE 4 // Maximum visible sprites per scanline
62 #define _SYS_CHROMA_KEY 0x4f // Chroma key MSB
63 #define _SYS_CKEY_BIT_EOL 0x40 // Chroma-key special bit, end-of-line
67 #define _SYS_VF_RESERVED 0x01 // Reserved, must be zero
68 #define _SYS_VF_TOGGLE 0x02 // Toggle bit, to trigger a new frame render
69 #define _SYS_VF_SYNC 0x04 // Sync with LCD vertical refresh
70 #define _SYS_VF_CONTINUOUS 0x08 // Render continuously, without waiting for toggle
71 #define _SYS_VF_A21 0x10 // Flash A21 bank select
72 #define _SYS_VF_XY_SWAP 0x20 // Swap X and Y axes during render
73 #define _SYS_VF_X_FLIP 0x40 // Flip X axis during render
74 #define _SYS_VF_Y_FLIP 0x80 // Flip Y axis during render
78 #define _SYS_VM_MASK 0x3c // Mask of valid bits in VM_MASK
80 #define _SYS_VM_POWERDOWN 0x00 // Power saving mode, LCD is off
81 #define _SYS_VM_BG0_ROM 0x04 // BG0, with tile data from internal ROM
82 #define _SYS_VM_SOLID 0x08 // Solid color, from colormap[0]
83 #define _SYS_VM_FB32 0x0c // 32x32 pixel 16-color framebuffer
84 #define _SYS_VM_FB64 0x10 // 64x64 pixel 2-color framebuffer
85 #define _SYS_VM_FB128 0x14 // 128x48 pixel 2-color framebuffer
86 #define _SYS_VM_BG0 0x18 // Background BG0: 18x18 grid
87 #define _SYS_VM_BG0_BG1 0x1c // BG0, plus overlay BG1: 16x16 bitmap + 144 indices
88 #define _SYS_VM_BG0_SPR_BG1 0x20 // BG0, multiple linear sprites, then BG1
89 #define _SYS_VM_BG2 0x24 // Background BG2: 16x16 grid with affine transform
90 #define _SYS_VM_STAMP 0x28 // Reconfigurable 16-color framebuffer with transparency
91 #define _SYS_VM_SLEEP 0x3c // Puts cube to sleep after fading out display
95 #define _SYS_VA_BG0_TILES 0x000
96 #define _SYS_VA_BG2_TILES 0x000
97 #define _SYS_VA_BG2_AFFINE 0x200
98 #define _SYS_VA_BG2_BORDER 0x20c
99 #define _SYS_VA_BG1_TILES 0x288
100 #define _SYS_VA_COLORMAP 0x300
101 #define _SYS_VA_BG1_BITMAP 0x3a8
102 #define _SYS_VA_SPR 0x3c8
103 #define _SYS_VA_BG1_XY 0x3f8
104 #define _SYS_VA_BG0_XY 0x3fa
105 #define _SYS_VA_FIRST_LINE 0x3fc
106 #define _SYS_VA_NUM_LINES 0x3fd
107 #define _SYS_VA_MODE 0x3fe
108 #define _SYS_VA_FLAGS 0x3ff
109 #define _SYS_VA_STAMP_PITCH 0x320
111 struct _SYSSpriteInfo {
138 uint8_t bytes[_SYS_VRAM_BYTES];
139 uint16_t words[_SYS_VRAM_WORDS];
142 uint16_t bg0_tiles[324];
143 uint16_t bg1_tiles[144];
144 uint16_t bg1_bitmap[16];
145 struct _SYSSpriteInfo spr[8];
158 uint16_t colormap[16];
160 uint8_t stamp_height;
167 uint16_t bg2_tiles[256];
168 struct _SYSAffine bg2_affine;
264 #define _SYS_VBF_NEED_PAINT (1 << 0) // Request a paint operation
267 struct _SYSVideoBuffer {
272 union _SYSVideoRAM vram;
282 struct _SYSAttachedVideoBuffer {
285 struct _SYSVideoBuffer vbuf;
294 #define _SYS_TILE77(_idx) ((((_idx) << 2) & 0xFE00) | \
295 (((_idx) << 1) & 0x00FE))
297 #define _SYS_INVERSE_TILE77(_t77) ((((_t77) & 0xFE00) >> 2) | \
298 (((_t77) & 0x00FE) >> 1))