junglejourney

view romloader.oph @ 216:cdceac4f5ea8

Started working on a ROM-based version of the game. Removed a generated file.
author David Boddie <david@boddie.org.uk>
date Sun Oct 16 18:25:22 2011 +0200
parents
children 59f37c9e74e4
line source
1 ; Copyright (C) 2011 David Boddie <david@boddie.org.uk>
2 ;
3 ; This program is free software: you can redistribute it and/or modify
4 ; it under the terms of the GNU General Public License as published by
5 ; the Free Software Foundation, either version 3 of the License, or
6 ; (at your option) any later version.
7 ;
8 ; This program is distributed in the hope that it will be useful,
9 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 ; GNU General Public License for more details.
12 ;
13 ; You should have received a copy of the GNU General Public License
14 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
16 .org $8000
17 rom_start:
18 jmp language_entry
19 jmp service_entry
21 ; ROM type
22 .byte $c2 ; 6502 code (2), language ($40), service ($80)
24 copyright_offset:
25 .byte [copyright_string - rom_start - 1]
27 ; Version
28 .byte 1
30 ; Title string
31 .byte "Jungle Journey (loader)", 0
33 ; Version string
34 .byte "1.0", 0
36 copyright_string:
37 .byte "(C) 2011 David Boddie", 0
39 ; Second processor relocation address
40 .byte 0, $80, 0, 0
42 language_entry:
44 jmp jungle_code
46 service_entry:
48 cmp #4
49 beq service_command
51 service_entry_exit:
52 rts
54 rom_name: .byte "JUNGLE"
56 service_command:
58 tya ; push Y and X registers onto the stack
59 pha
60 txa
61 pha
63 ldx #0
64 service_command_loop:
66 lda ($f2),y
67 cmp rom_name,x
68 bne service_command_exit
69 inx
70 iny
71 cpx #10
72 bne service_command_loop
74 jsr jungle_code
75 lda #0
76 rts
78 service_command_exit:
79 pla ; pop Y and X registers off the stack
80 tax
81 pha
82 tay
83 lda #4 ; restore A
84 rts
86 jungle_code:
88 lda #22 ; MODE 5
89 jsr $ffee
90 lda #5
91 jsr $ffee
93 lda #23 ; disable flashing cursor
94 jsr $ffee
95 lda #1
96 jsr $ffee
97 ldx #7
98 cursor_loop:
99 lda #0
100 jsr $ffee
101 dex
102 bpl cursor_loop
104 jsr set_hidden_palette
106 ; Define ENVELOPEs.
107 lda #0
108 sta $70
109 define_envelopes_loop:
111 ldx $70
112 lda envelopes_high,x
113 tay
114 lda envelopes_low,x
115 tax
116 lda #8
117 jsr $fff1
119 inc $70
120 lda $70
121 cmp #4
122 bne define_envelopes_loop
124 jsr copy_title_from_rom
126 lda #140
127 jsr $fff4 ; *TAPE
129 jsr copy_title_down
130 jsr move_completed_screen_down
131 jsr copy_sprites_from_rom
132 jsr copy_chars_from_rom
134 lda #129 ; returns y=255 or 0
135 ldx #157 ; SPACE
136 ldy #255
137 wait_loop:
138 jsr $fff4
139 cpy #255
140 bne wait_loop
142 ldx #<start_game
143 ldy #>start_game
144 jsr $fff7
145 rts
147 start_game: .byte "*JUNGLECODE", 13, 0
149 set_hidden_palette:
151 lda #1
152 sta $70
153 lda #0
154 sta $71
155 jsr set_palette
157 ; Run on into the next routine.
159 set_core_palette:
161 lda #2
162 sta $70
163 lda #2
164 sta $71
165 jsr set_palette
167 lda #3
168 sta $70
169 lda #3
170 sta $71
171 jsr set_palette
173 rts
175 set_palette:
176 ; $70=logical colour
177 ; $71=physical colour
178 lda $70
179 sta $3dfb
180 lda $71
181 sta $3dfc
182 lda #0
183 sta $3dfd
184 sta $3dfe
185 sta $3dff
187 lda #$c
188 ldx #$fb
189 ldy #$3d
190 jsr $fff1
191 rts
193 envelopes_low: .byte <explosion_envelope, <damage_envelope, <item_envelope, <key_envelope
194 envelopes_high: .byte >explosion_envelope, >damage_envelope, >item_envelope, >key_envelope
196 explosion_envelope: .byte 1,1,252,0,0,10,0,0,126,0,0,130,126,126
197 damage_envelope: .byte 2,4,8,0,248,2,0,2,126,0,0,130,126,126
198 item_envelope: .byte 3,2,8,4,2,10,10,10,126,0,0,130,126,126
199 key_envelope: .byte 4,2,4,40,0,8,1,3,126,0,0,130,126,126
201 copy_title_from_rom:
203 lda #$00
204 sta $70
205 lda #$83
206 sta $71
208 lda #$a0
209 sta $72
210 lda #$5a
211 sta $73
213 ldx #$17
215 copy_title_from_rom_loop1:
217 ldy #0
218 copy_title_from_rom_loop2:
220 lda ($70),y
221 sta ($72),y
222 iny
223 cpy #0
224 bne copy_title_from_rom_loop2
226 clc
227 lda $72
228 adc #$40
229 sta $72
230 lda $73
231 adc #$01
232 sta $73
233 clc
235 lda $71
236 adc #$01
237 sta $71
239 dex
240 bpl copy_title_from_rom_loop1
242 clc
243 rts
245 copy_title_down:
247 lda #$a0
248 sta $70
249 lda #$5a
250 sta $71
252 lda #$00
253 sta $72
254 lda #$18
255 sta $73
257 ldx #$05
259 copy_title_down_loop1:
261 ldy #0
262 copy_title_down_loop2:
264 lda ($70),y
265 sta ($72),y
266 iny
267 cpy #0
268 bne copy_title_down_loop2
270 clc
271 lda $70
272 adc #$40
273 sta $70
274 lda $71
275 adc #$01
276 sta $71
277 clc
279 lda $73
280 adc #$01
281 sta $73
283 dex
284 bpl copy_title_down_loop1
286 clc
287 rts
289 move_completed_screen_down:
291 lda #$20
292 sta $70
293 lda #$62
294 sta $71
296 lda #$00
297 sta $72
298 lda #$0f
299 sta $73
301 ldx #128
303 move_completed_screen_loop:
305 ldy #1
306 lda ($70),y
307 and #$0f
308 asl
309 asl
310 asl
311 asl
312 sta $80
313 dey
314 lda ($70),y
315 and #$0f
316 ora $80
317 sta ($72),y
319 lda #0
320 sta ($70),y
321 iny
322 sta ($70),y
324 clc
325 lda $70
326 adc #2
327 sta $70
328 lda $71
329 adc #0
330 sta $71
331 clc
333 lda $72
334 adc #1
335 sta $72
336 lda $73
337 adc #0
338 sta $73
339 clc
341 dex
342 cpx #0
343 bne move_completed_screen_next
345 ldx #128
347 clc
348 lda $70
349 adc #$40
350 sta $70
351 lda $71
352 adc #$00
353 sta $71
354 clc
356 move_completed_screen_next:
357 clc
359 lda $72
360 cmp #$00
361 bne move_completed_screen_loop
363 lda $73
364 cmp #$18
365 bne move_completed_screen_loop
367 clc
368 rts
370 copy_sprites_from_rom:
372 lda #$80
373 sta $70
374 lda #$ad
375 sta $71
377 lda #$00
378 sta $72
379 lda #$54
380 sta $73
382 ldx #$35
384 copy_sprites_from_rom_loop1:
386 ldy #0
387 copy_sprites_from_rom_loop2:
389 lda ($70),y
390 sta ($72),y
391 iny
392 cpy #16
393 bne copy_sprites_from_rom_loop2
395 clc
396 lda $70
397 adc #$10
398 sta $70
399 lda $71
400 adc #$00
401 sta $71
402 clc
404 lda $72
405 adc #$10
406 sta $72
407 lda $73
408 adc #$00
409 sta $73
410 clc
412 dex
413 bpl copy_sprites_from_rom_loop1
415 clc
416 rts
418 copy_chars_from_rom:
420 lda #$00
421 sta $70
422 lda #$9b
423 sta $71
425 lda #$00
426 sta $72
427 lda #$3f
428 sta $73
430 copy_chars_from_rom_loop1:
432 ldy #0
433 copy_chars_from_rom_loop2:
435 lda ($70),y
436 sta ($72),y
437 iny
438 cpy #$80
439 bne copy_chars_from_rom_loop2
441 clc
442 lda $70
443 adc #$80
444 sta $70
445 lda $71
446 adc #$00
447 sta $71
448 clc
450 lda $72
451 adc #$80
452 sta $72
453 lda $73
454 adc #$00
455 sta $73
456 clc
458 cmp #$ad
459 bne copy_chars_from_rom_loop1
460 lda $72
461 cmp #$80
462 bne copy_chars_from_rom_loop1
464 clc
465 rts