7 #ifndef _SIFTEO_ABI_VRAM_H
8 #define _SIFTEO_ABI_VRAM_H
10 #include <sifteo/abi/types.h>
30 #define _SYS_VRAM_BYTES 1024
31 #define _SYS_VRAM_BYTE_MASK (_SYS_VRAM_BYTES - 1)
34 #define _SYS_VRAM_WORDS (_SYS_VRAM_BYTES / 2)
35 #define _SYS_VRAM_WORD_MASK (_SYS_VRAM_WORDS - 1)
37 #define _SYS_VRAM_BG0_WIDTH 18 // Width/height of BG0 tile grid
38 #define _SYS_VRAM_BG1_WIDTH 16 // Width/height of BG1 bitmap
39 #define _SYS_VRAM_BG1_TILES 144 // Total number of opaque tiles in BG1
40 #define _SYS_VRAM_BG2_WIDTH 16 // Width/height of BG2 tile grid
41 #define _SYS_VRAM_SPRITES 8 // Total number of linear sprites
42 #define _SYS_SPRITES_PER_LINE 4 // Maximum visible sprites per scanline
43 #define _SYS_CHROMA_KEY 0x4f // Chroma key MSB
44 #define _SYS_CKEY_BIT_EOL 0x40 // Chroma-key special bit, end-of-line
48 #define _SYS_VF_RESERVED 0x01 // Reserved, must be zero
49 #define _SYS_VF_TOGGLE 0x02 // Toggle bit, to trigger a new frame render
50 #define _SYS_VF_SYNC 0x04 // Sync with LCD vertical refresh
51 #define _SYS_VF_CONTINUOUS 0x08 // Render continuously, without waiting for toggle
52 #define _SYS_VF_A21 0x10 // Flash A21 bank select
53 #define _SYS_VF_XY_SWAP 0x20 // Swap X and Y axes during render
54 #define _SYS_VF_X_FLIP 0x40 // Flip X axis during render
55 #define _SYS_VF_Y_FLIP 0x80 // Flip Y axis during render
59 #define _SYS_VM_MASK 0x3c // Mask of valid bits in VM_MASK
61 #define _SYS_VM_POWERDOWN 0x00 // Power saving mode, LCD is off
62 #define _SYS_VM_BG0_ROM 0x04 // BG0, with tile data from internal ROM
63 #define _SYS_VM_SOLID 0x08 // Solid color, from colormap[0]
64 #define _SYS_VM_FB32 0x0c // 32x32 pixel 16-color framebuffer
65 #define _SYS_VM_FB64 0x10 // 64x64 pixel 2-color framebuffer
66 #define _SYS_VM_FB128 0x14 // 128x48 pixel 2-color framebuffer
67 #define _SYS_VM_BG0 0x18 // Background BG0: 18x18 grid
68 #define _SYS_VM_BG0_BG1 0x1c // BG0, plus overlay BG1: 16x16 bitmap + 144 indices
69 #define _SYS_VM_BG0_SPR_BG1 0x20 // BG0, multiple linear sprites, then BG1
70 #define _SYS_VM_BG2 0x24 // Background BG2: 16x16 grid with affine transform
71 #define _SYS_VM_STAMP 0x28 // Reconfigurable 16-color framebuffer with transparency
72 #define _SYS_VM_SLEEP 0x3c // Puts cube to sleep after fading out display
76 #define _SYS_VA_BG0_TILES 0x000
77 #define _SYS_VA_BG2_TILES 0x000
78 #define _SYS_VA_BG2_AFFINE 0x200
79 #define _SYS_VA_BG2_BORDER 0x20c
80 #define _SYS_VA_BG1_TILES 0x288
81 #define _SYS_VA_COLORMAP 0x300
82 #define _SYS_VA_BG1_BITMAP 0x3a8
83 #define _SYS_VA_SPR 0x3c8
84 #define _SYS_VA_BG1_XY 0x3f8
85 #define _SYS_VA_BG0_XY 0x3fa
86 #define _SYS_VA_FIRST_LINE 0x3fc
87 #define _SYS_VA_NUM_LINES 0x3fd
88 #define _SYS_VA_MODE 0x3fe
89 #define _SYS_VA_FLAGS 0x3ff
90 #define _SYS_VA_STAMP_PITCH 0x320
92 struct _SYSSpriteInfo {
119 uint8_t bytes[_SYS_VRAM_BYTES];
120 uint16_t words[_SYS_VRAM_WORDS];
123 uint16_t bg0_tiles[324];
124 uint16_t bg1_tiles[144];
125 uint16_t bg1_bitmap[16];
126 struct _SYSSpriteInfo spr[8];
139 uint16_t colormap[16];
141 uint8_t stamp_height;
148 uint16_t bg2_tiles[256];
149 struct _SYSAffine bg2_affine;
245 #define _SYS_VBF_NEED_PAINT (1 << 0) // Request a paint operation
248 struct _SYSVideoBuffer {
253 union _SYSVideoRAM vram;
263 struct _SYSAttachedVideoBuffer {
266 struct _SYSVideoBuffer vbuf;
275 #define _SYS_TILE77(_idx) ((((_idx) << 2) & 0xFE00) | \
276 (((_idx) << 1) & 0x00FE))
278 #define _SYS_INVERSE_TILE77(_t77) ((((_t77) & 0xFE00) >> 2) | \
279 (((_t77) & 0x00FE) >> 1))