# HG changeset patch # User David Boddie # Date 1318782322 -7200 # Node ID cdceac4f5ea85f987beb899fbc91f37e98c72f06 # Parent 3ae571b43ba0724ca1c96b2e4bf5bb7be802fa3c Started working on a ROM-based version of the game. Removed a generated file. diff -r 3ae571b43ba0 -r cdceac4f5ea8 LOADER --- a/LOADER Sun Oct 16 03:04:19 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -AUTO -MODE 6 -OSCLI("LOAD CODE") -OSCLI("LOAD SPRITES") - -MODE 5 -VDU 23,1,0;0;0;0; -VDU 19,2,2,0,0,0 -VDU 19,3,3,0,0,0 - -?&78=5 -?&79=5 - -REPEAT -CALL &{addr} - -A% = GET -IF A%=90 AND ?&79>0 THEN ?&79=?&79-1 -IF A%=88 AND ?&79<10 THEN ?&79=?&79+1 -IF A%=58 AND ?&78>0 THEN ?&78=?&78-1 -IF A%=47 AND ?&78<10 THEN ?&78=?&78+1 - -UNTIL FALSE diff -r 3ae571b43ba0 -r cdceac4f5ea8 buildrom.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/buildrom.py Sun Oct 16 18:25:22 2011 +0200 @@ -0,0 +1,75 @@ +#!/usr/bin/env python + +""" +Copyright (C) 2011 David Boddie + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +""" + +from build import * + +if __name__ == "__main__": + + if not 1 <= len(sys.argv) <= 3: + + sys.stderr.write("Usage: %s [ ]\n" % sys.argv[0]) + sys.exit(1) + + if len(sys.argv) == 3: + code_rom_file = sys.argv[1] + loader_rom_file = sys.argv[2] + else: + code_rom_file = "junglecode.rom" + loader_rom_file = "jungle.rom" + + # Memory map + # + # 8000 ROM header code + # CODE + # + # 8000 ROM header code + # 8300 title screen (0x1800 bytes including completion screen) + # + # 9B00 CHARS (0x1280 bytes of character sprites) + # AD80 SPRITES (0x360 bytes of tile sprites) + # B0E0 space + + system("ophis romcode.oph " + code_rom_file) + + # Add padding after the code to make a final image size of 16K. + romcode = open("junglecode.rom", "rb").read() + romcode += (0x4000 - len(romcode))*"\x00" + open(code_rom_file, "wb").write(romcode) + + system("ophis romloader.oph " + loader_rom_file) + + romdata = open(loader_rom_file, "rb").read() + + # Add padding before the data is appended to the loader code. + romdata += (0x300 - len(romdata))*"\x00" + + data = makesprites.read_sprites([makesprites.title]) + completed = makesprites.encode(makesprites.read_sprite(makesprites.completed)) + overlay = makesprites.read_sprite(makesprites.overlay) + combined = makesprites.combine(completed, overlay) + romdata += combined + + romdata += makesprites.read_sprites(makesprites.tiles) + romdata += makesprites.read_sprites(makesprites.chars) + romdata += (0x4000 - len(romdata))*"\x00" + + open(loader_rom_file, "wb").write(romdata) + + # Exit + sys.exit() diff -r 3ae571b43ba0 -r cdceac4f5ea8 mapcode.oph --- a/mapcode.oph Sun Oct 16 03:04:19 2011 +0200 +++ b/mapcode.oph Sun Oct 16 18:25:22 2011 +0200 @@ -788,9 +788,6 @@ rts -tile_addresses_low: .byte $00, $60, $c0, $00, $60, $c0, $20 -tile_addresses_high: .byte $54, $54, $54, $50, $50, $50, $51 - plot_tile: ; $7b=tile number ; 1 = flowers/decoration ; 2 = trees/wall @@ -1318,9 +1315,6 @@ jsr $fff4 rts -player_direction_chars_low: .byte $00,$30,$60,$90,$c0,$f0,$20,$50, $80,$b0,$e0,$10 -player_direction_chars_high: .byte $3f,$3f,$3f,$3f,$3f,$3f,$40,$40, $40,$40,$40,$41 - screen_rows_low: .byte $80,$40,$00,$c0,$80,$40,$00,$c0,$80,$40 screen_rows_high: .byte $5a,$5e,$62,$65,$69,$6d,$71,$74,$78,$7c screen_subrows_low: .byte $00,$06,$44,$82 @@ -1330,17 +1324,6 @@ screen_columns_high: .byte $00,$00,$00,$00,$00,$00,$00,$00,$01,$01 screen_subcolumns_low: .byte $00,$08,$10,$18 -enemy_direction_chars_low: .byte $c0,$00,$40,$80,$c0,$00,$40,$80 -enemy_direction_chars_high: .byte $41,$42,$42,$42,$42,$43,$43,$43 - -emerge_explode_chars_low: .byte $c0,$00,$40,$80,$c0,$00,$40,$80 -emerge_explode_chars_high: .byte $4b,$4c,$4c,$4c,$4c,$4d,$4d,$4d - -item_chars_low: .byte $c0,$00,$40,$80,$c0,$00,$40,$80,$c0 -item_chars_high: .byte $4d,$4e,$4e,$4e,$4e,$4f,$4f,$4f,$4f - -projectile_chars_low: .byte $40,$50,$60,$70,$80,$90,$a0,$b0 - unplot_character: ; $74,$75=character address lda $82 ; store the unplot buffer address in $78,$79 @@ -1461,7 +1444,7 @@ tax lda projectile_chars_low,x sta $70 - lda #$41 + lda #projectile_chars_high sta $71 ; Use the dy value to determine which plotting routine to use. diff -r 3ae571b43ba0 -r cdceac4f5ea8 romcode.oph --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/romcode.oph Sun Oct 16 18:25:22 2011 +0200 @@ -0,0 +1,106 @@ +; Copyright (C) 2011 David Boddie +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU General Public License as published by +; the Free Software Foundation, either version 3 of the License, or +; (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this program. If not, see . + +.org $8000 +rom_start: +jmp language_entry +jmp service_entry + +; ROM type +.byte $c2 ; 6502 code (2), language ($40), service ($80) + +copyright_offset: +.byte [copyright_string - rom_start - 1] + +; Version +.byte 1 + +; Title string +.byte "Jungle Journey (code)", 0 + +; Version string +.byte "1.0", 0 + +copyright_string: +.byte "(C) 2011 David Boddie", 0 + +; Second processor relocation address +.byte 0, $80, 0, 0 + +language_entry: + + jmp jungle_code + +service_entry: + + cmp #4 + beq service_command + + service_entry_exit: + rts + +rom_name: .byte "JUNGLECODE" + +service_command: + + tya ; push Y and X registers onto the stack + pha + txa + pha + + ldx #0 + service_command_loop: + + lda ($f2),y + cmp rom_name,x + bne service_command_exit + inx + iny + cpx #10 + bne service_command_loop + + jsr jungle_code + lda #0 + rts + + service_command_exit: + pla ; pop Y and X registers off the stack + tax + pha + tay + lda #4 ; restore A + rts + +jungle_code: + +.include "mapcode.oph" + +tile_addresses_low: .byte $00, $60, $c0, $00, $60, $c0, $20 +tile_addresses_high: .byte $54, $54, $54, $50, $50, $50, $51 + +player_direction_chars_low: .byte $00,$30,$60,$90,$c0,$f0,$20,$50, $80,$b0,$e0,$10 +player_direction_chars_high: .byte $3f,$3f,$3f,$3f,$3f,$3f,$40,$40, $40,$40,$40,$41 + +enemy_direction_chars_low: .byte $c0,$00,$40,$80,$c0,$00,$40,$80 +enemy_direction_chars_high: .byte $41,$42,$42,$42,$42,$43,$43,$43 + +emerge_explode_chars_low: .byte $c0,$00,$40,$80,$c0,$00,$40,$80 +emerge_explode_chars_high: .byte $4b,$4c,$4c,$4c,$4c,$4d,$4d,$4d + +item_chars_low: .byte $c0,$00,$40,$80,$c0,$00,$40,$80,$c0 +item_chars_high: .byte $4d,$4e,$4e,$4e,$4e,$4f,$4f,$4f,$4f + +projectile_chars_low: .byte $40,$50,$60,$70,$80,$90,$a0,$b0 +.alias projectile_chars_high $41 diff -r 3ae571b43ba0 -r cdceac4f5ea8 romloader.oph --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/romloader.oph Sun Oct 16 18:25:22 2011 +0200 @@ -0,0 +1,465 @@ +; Copyright (C) 2011 David Boddie +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU General Public License as published by +; the Free Software Foundation, either version 3 of the License, or +; (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this program. If not, see . + +.org $8000 +rom_start: +jmp language_entry +jmp service_entry + +; ROM type +.byte $c2 ; 6502 code (2), language ($40), service ($80) + +copyright_offset: +.byte [copyright_string - rom_start - 1] + +; Version +.byte 1 + +; Title string +.byte "Jungle Journey (loader)", 0 + +; Version string +.byte "1.0", 0 + +copyright_string: +.byte "(C) 2011 David Boddie", 0 + +; Second processor relocation address +.byte 0, $80, 0, 0 + +language_entry: + + jmp jungle_code + +service_entry: + + cmp #4 + beq service_command + + service_entry_exit: + rts + +rom_name: .byte "JUNGLE" + +service_command: + + tya ; push Y and X registers onto the stack + pha + txa + pha + + ldx #0 + service_command_loop: + + lda ($f2),y + cmp rom_name,x + bne service_command_exit + inx + iny + cpx #10 + bne service_command_loop + + jsr jungle_code + lda #0 + rts + + service_command_exit: + pla ; pop Y and X registers off the stack + tax + pha + tay + lda #4 ; restore A + rts + +jungle_code: + + lda #22 ; MODE 5 + jsr $ffee + lda #5 + jsr $ffee + + lda #23 ; disable flashing cursor + jsr $ffee + lda #1 + jsr $ffee + ldx #7 + cursor_loop: + lda #0 + jsr $ffee + dex + bpl cursor_loop + + jsr set_hidden_palette + + ; Define ENVELOPEs. + lda #0 + sta $70 + define_envelopes_loop: + + ldx $70 + lda envelopes_high,x + tay + lda envelopes_low,x + tax + lda #8 + jsr $fff1 + + inc $70 + lda $70 + cmp #4 + bne define_envelopes_loop + + jsr copy_title_from_rom + + lda #140 + jsr $fff4 ; *TAPE + + jsr copy_title_down + jsr move_completed_screen_down + jsr copy_sprites_from_rom + jsr copy_chars_from_rom + + lda #129 ; returns y=255 or 0 + ldx #157 ; SPACE + ldy #255 + wait_loop: + jsr $fff4 + cpy #255 + bne wait_loop + + ldx #start_game + jsr $fff7 + rts + +start_game: .byte "*JUNGLECODE", 13, 0 + +set_hidden_palette: + + lda #1 + sta $70 + lda #0 + sta $71 + jsr set_palette + + ; Run on into the next routine. + +set_core_palette: + + lda #2 + sta $70 + lda #2 + sta $71 + jsr set_palette + + lda #3 + sta $70 + lda #3 + sta $71 + jsr set_palette + + rts + +set_palette: + ; $70=logical colour + ; $71=physical colour + lda $70 + sta $3dfb + lda $71 + sta $3dfc + lda #0 + sta $3dfd + sta $3dfe + sta $3dff + + lda #$c + ldx #$fb + ldy #$3d + jsr $fff1 + rts + +envelopes_low: .byte explosion_envelope, >damage_envelope, >item_envelope, >key_envelope + +explosion_envelope: .byte 1,1,252,0,0,10,0,0,126,0,0,130,126,126 +damage_envelope: .byte 2,4,8,0,248,2,0,2,126,0,0,130,126,126 +item_envelope: .byte 3,2,8,4,2,10,10,10,126,0,0,130,126,126 +key_envelope: .byte 4,2,4,40,0,8,1,3,126,0,0,130,126,126 + +copy_title_from_rom: + + lda #$00 + sta $70 + lda #$83 + sta $71 + + lda #$a0 + sta $72 + lda #$5a + sta $73 + + ldx #$17 + + copy_title_from_rom_loop1: + + ldy #0 + copy_title_from_rom_loop2: + + lda ($70),y + sta ($72),y + iny + cpy #0 + bne copy_title_from_rom_loop2 + + clc + lda $72 + adc #$40 + sta $72 + lda $73 + adc #$01 + sta $73 + clc + + lda $71 + adc #$01 + sta $71 + + dex + bpl copy_title_from_rom_loop1 + + clc + rts + +copy_title_down: + + lda #$a0 + sta $70 + lda #$5a + sta $71 + + lda #$00 + sta $72 + lda #$18 + sta $73 + + ldx #$05 + + copy_title_down_loop1: + + ldy #0 + copy_title_down_loop2: + + lda ($70),y + sta ($72),y + iny + cpy #0 + bne copy_title_down_loop2 + + clc + lda $70 + adc #$40 + sta $70 + lda $71 + adc #$01 + sta $71 + clc + + lda $73 + adc #$01 + sta $73 + + dex + bpl copy_title_down_loop1 + + clc + rts + +move_completed_screen_down: + + lda #$20 + sta $70 + lda #$62 + sta $71 + + lda #$00 + sta $72 + lda #$0f + sta $73 + + ldx #128 + + move_completed_screen_loop: + + ldy #1 + lda ($70),y + and #$0f + asl + asl + asl + asl + sta $80 + dey + lda ($70),y + and #$0f + ora $80 + sta ($72),y + + lda #0 + sta ($70),y + iny + sta ($70),y + + clc + lda $70 + adc #2 + sta $70 + lda $71 + adc #0 + sta $71 + clc + + lda $72 + adc #1 + sta $72 + lda $73 + adc #0 + sta $73 + clc + + dex + cpx #0 + bne move_completed_screen_next + + ldx #128 + + clc + lda $70 + adc #$40 + sta $70 + lda $71 + adc #$00 + sta $71 + clc + + move_completed_screen_next: + clc + + lda $72 + cmp #$00 + bne move_completed_screen_loop + + lda $73 + cmp #$18 + bne move_completed_screen_loop + + clc + rts + +copy_sprites_from_rom: + + lda #$80 + sta $70 + lda #$ad + sta $71 + + lda #$00 + sta $72 + lda #$54 + sta $73 + + ldx #$35 + + copy_sprites_from_rom_loop1: + + ldy #0 + copy_sprites_from_rom_loop2: + + lda ($70),y + sta ($72),y + iny + cpy #16 + bne copy_sprites_from_rom_loop2 + + clc + lda $70 + adc #$10 + sta $70 + lda $71 + adc #$00 + sta $71 + clc + + lda $72 + adc #$10 + sta $72 + lda $73 + adc #$00 + sta $73 + clc + + dex + bpl copy_sprites_from_rom_loop1 + + clc + rts + +copy_chars_from_rom: + + lda #$00 + sta $70 + lda #$9b + sta $71 + + lda #$00 + sta $72 + lda #$3f + sta $73 + + copy_chars_from_rom_loop1: + + ldy #0 + copy_chars_from_rom_loop2: + + lda ($70),y + sta ($72),y + iny + cpy #$80 + bne copy_chars_from_rom_loop2 + + clc + lda $70 + adc #$80 + sta $70 + lda $71 + adc #$00 + sta $71 + clc + + lda $72 + adc #$80 + sta $72 + lda $73 + adc #$00 + sta $73 + clc + + cmp #$ad + bne copy_chars_from_rom_loop1 + lda $72 + cmp #$80 + bne copy_chars_from_rom_loop1 + + clc + rts diff -r 3ae571b43ba0 -r cdceac4f5ea8 tapecode.oph --- a/tapecode.oph Sun Oct 16 03:04:19 2011 +0200 +++ b/tapecode.oph Sun Oct 16 18:25:22 2011 +0200 @@ -15,3 +15,21 @@ .org $1e00 .include "mapcode.oph" + +tile_addresses_low: .byte $00, $60, $c0, $00, $60, $c0, $20 +tile_addresses_high: .byte $54, $54, $54, $50, $50, $50, $51 + +player_direction_chars_low: .byte $00,$30,$60,$90,$c0,$f0,$20,$50, $80,$b0,$e0,$10 +player_direction_chars_high: .byte $3f,$3f,$3f,$3f,$3f,$3f,$40,$40, $40,$40,$40,$41 + +enemy_direction_chars_low: .byte $c0,$00,$40,$80,$c0,$00,$40,$80 +enemy_direction_chars_high: .byte $41,$42,$42,$42,$42,$43,$43,$43 + +emerge_explode_chars_low: .byte $c0,$00,$40,$80,$c0,$00,$40,$80 +emerge_explode_chars_high: .byte $4b,$4c,$4c,$4c,$4c,$4d,$4d,$4d + +item_chars_low: .byte $c0,$00,$40,$80,$c0,$00,$40,$80,$c0 +item_chars_high: .byte $4d,$4e,$4e,$4e,$4e,$4f,$4f,$4f,$4f + +projectile_chars_low: .byte $40,$50,$60,$70,$80,$90,$a0,$b0 +.alias projectile_chars_high $41