-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheader.inc
66 lines (52 loc) · 1.19 KB
/
header.inc
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
IF !DEF(HEADER_INC)
HEADER_INC SET 1
; copy x-bytes to [de]
SECTION "Copy Data",ROM0[$28]
CopyData:
; pop return address off stack into hl
pop hl
push bc
; here we get the number of bytes to copy
; hl contains the address of the bytes following the "rst $28" call
; put first byte into b ($00 in this context)
ld a,[hli]
ld b,a
; put second byte into c ($0D in this context)
ld a,[hli]
ld c,a
; bc now contains $000D
; hl now points to the first byte of our assembled subroutine (which is $F5)
; begin copying data
.copyDataLoop
; load a byte of data into a
ld a,[hli]
; store the byte in de, our destination ($FF80 in this context)
ld [de],a
; go to the next destination byte, decrease counter
inc de
dec bc
; check if counter is zero, if not repeat loop
ld a,b
or c
jr nz,.copyDataLoop
; all done, return home
pop bc
jp hl
reti
SECTION "VBlank", ROM0[$0040]
VBlank:
ld a, [_ANIM_COUNTER]
inc a
cp 20
jr nz, .endVBlank
xor a ; ld a, 0
.endVBlank
ld [_ANIM_COUNTER], a
reti
SECTION "ROM_entry_point", ROM0[$0100] ; ROM is given control from boot here
nop
jp Main
REPT $150 - $104
db 0
ENDR
ENDC ;HEADER_INC