-
Notifications
You must be signed in to change notification settings - Fork 2
/
puzzles.asm
142 lines (110 loc) · 1.81 KB
/
puzzles.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
.include "header.inc"
.include "puzzles.inc"
.include "misc_macros.inc"
.16bit
.ramsection "puzzle buffer" SLOT RAM_SLOT
puzzle_buffer: dsb 81
puzzle_level: dw
puzzle_id: dw
.ends
.bank 0
.section "Puzzle loader" FREE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Initialize puzzle_buffer with a blank puzzle
;
puzzles_loadEmpty:
Memset puzzle_buffer 0 _sizeof_puzzle_buffer
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Load a puzzle from ROM to a RAM buffer
;
;
puzzles_load:
pushall
A16
XY16
; Multiply puzzle ID by puzzle size (128)
lda puzzle_id
asl
asl
asl
asl
asl
asl
asl
tax
A8
lda puzzle_level
beq @simple_load
cmp #1
beq @easy_load
cmp #2
beq @intermediate_load
cmp #3
beq @expert_load
@simple_load:
ldy #0 ; counter for 81 bytes
@simple_loop:
lda puzzles_simple.L, X
sta puzzle_buffer, Y
inx
iny
cpy #81
bne @simple_loop
bra @done
@easy_load:
ldy #0 ; counter for 81 bytes
@easy_loop:
lda puzzles_easy.L, X
sta puzzle_buffer, Y
inx
iny
cpy #81
bne @easy_loop
bra @done
@intermediate_load:
ldy #0 ; counter for 81 bytes
@intermediate_loop:
lda puzzles_intermediate.L, X
sta puzzle_buffer, Y
inx
iny
cpy #81
bne @intermediate_loop
bra @done
@expert_load:
ldy #0 ; counter for 81 bytes
@expert_loop:
lda puzzles_expert.L, X
sta puzzle_buffer, Y
inx
iny
cpy #81
bne @expert_loop
bra @done
@done:
popall
rts
.ends
.bank 1
.section "Simple puzzles" FREE
puzzles_simple:
.incbin "puzzles/simple.bin"
.ends
.bank 2
.section "Easy puzzles" FREE
puzzles_easy:
.incbin "puzzles/easy.bin"
.ends
.bank 3
.section "Intermediate puzzles" FREE
puzzles_intermediate:
.incbin "puzzles/intermediate.bin"
.ends
.bank 4
.section "Expert puzzles" FREE
puzzles_expert:
.incbin "puzzles/expert.bin"
.ends