1 ; vi:filetype=nasm ts=8 sts=8 sw=8:
6 ; initializes the video hardware and graphics routines
8 ; clears the framebuffer (not vmem)
9 ; clobbers: eax, ecx, edi
11 ; copies the framebuffer to video memory
12 ; clobbers: eax, ecx, edi, esi
15 ; set_palette_entry(idx[al], r[ah], g[bl], b[bh])
20 VIDMEM_ADDR equ 0a0000h
21 FRAMEBUF_ADDR equ 090000h
23 REG_CRTC_STATUS equ 3dah
24 CRTC_VBLANK_BIT equ 08h
37 ; setup the spritesheet palette
38 mov esi, sprsheet_cmap
46 call set_palette_entry
50 ; force color 0 to black
53 call set_palette_entry
59 mov edi, FRAMEBUF_ADDR
67 mov esi, FRAMEBUF_ADDR
75 mov dx, REG_CRTC_STATUS
78 and al, CRTC_VBLANK_BIT
82 and al, CRTC_VBLANK_BIT
90 inc dx ; dx <- REG_DAC_DATA
103 ; slow_sprite(int id, int x, int y)
104 ; assumptions: 32x32, one after the other, 0 is transparent
111 mov eax, [ebp + 16] ; ax <- y
112 sub eax, 16 ; ax <- y - 16 (center sprite vertically)
116 add eax, ebx ; ax <- (y - 16) * 320
117 mov edi, [ebp + 12] ; di <- x
118 sub edi, 16 ; di <- x - 16 (center sprite horizontally)
119 add edi, eax ; di <- (y - 16) * 320 + (x - 16)
120 add edi, FRAMEBUF_ADDR
122 mov esi, sprsheet_tiles
123 ; calculate sprite id offset (each spr is 32*32=1k)