-
Notifications
You must be signed in to change notification settings - Fork 0
/
hblank_experiments.asm
71 lines (58 loc) · 1.11 KB
/
hblank_experiments.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
mov a VM
str a x2 ; enable tile mode
mov a BG_ENABLE
str a x2 ; turn on BG1
mov a IH
mov b interrupt_handler
str a b ; IH = interrupt_handler
sub a xE ; IH - xF = IE
str a x3 ; IE = VBLANK | HBLANK
sub a x2 ; IE - x2 = IME
str a x1 ; IME enabled
mov a palettes
mov b PAL
mov c 4
bl 0x0004 ; bios mem_cpy function
mov a tiles
mov b VRAM
mov c 8
bl 0x0004 ; bios mem_cpy function
loop:
bl vblank_wait ; wait for vblank
b loop
interrupt_handler:
push a-b
mov a vblank_wait_flag
str a x1 ; set vblank_wait_flag
mov a PAL
ldr b a
sub b 0x7C00
bz +4
mov b 0x7C00
b end
mov b 0x1F
end:
str a b
pop a-b
ret
vblank_wait:
push a-b
mov a vblank_wait_flag
ldr b a
bz -2 ; loop ldr/bz
str a x0 ; clear vblank_wait_flag
pop a-b
ret
vblank_wait_flag:
.data
0x0000
.enddata
palettes:
.data
; black/white
0x7C00,0x0000,0x0000,0x0000
.enddata
tiles:
.data
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
.enddata