junglejourney
changeset 17:ae5f572644bd
Added code to clear the starting room.
Added placeholder code to test movement between screens.
| author | David Boddie <david@boddie.org.uk> |
|---|---|
| date | Sat Aug 13 15:45:29 2011 +0200 |
| parents | acc98c3592fd |
| children | ddb15fb07db6 |
| files | build.py mapcode.oph |
| diffstat | 2 files changed, 109 insertions(+), 24 deletions(-) [+] |
line diff
1.1 --- a/build.py Sat Aug 13 03:05:46 2011 +0200 1.2 +++ b/build.py Sat Aug 13 15:45:29 2011 +0200 1.3 @@ -59,9 +59,10 @@ 1.4 # second character is always the player's weapon 1.5 # new characters are added 1.6 # 1.7 - # 4FF0 current room (i, j) 1.8 - # 4FF2 lives 1.9 - # 4FF4 score (two bytes) 1.10 + # 4FF0 starting room (i, j) 1.11 + # 4FF2 current room (i, j) 1.12 + # 4FF4 lives 1.13 + # 4FF6 score (four bytes) 1.14 # 4FFB palette workspace (enough for one 5 byte palette entry) 1.15 # 1.16 # 5000 CHARS (character sprites)
2.1 --- a/mapcode.oph Sat Aug 13 03:05:46 2011 +0200 2.2 +++ b/mapcode.oph Sat Aug 13 15:45:29 2011 +0200 2.3 @@ -258,6 +258,39 @@ 2.4 do_bottom_exit: 2.5 jsr draw_bottom_line 2.6 2.7 + ; Make sure that the starting room is empty. 2.8 + 2.9 + lda $78 2.10 + cmp $4ff0 2.11 + bne not_starting_room 2.12 + lda $79 2.13 + cmp $4ff1 2.14 + bne not_starting_room 2.15 + 2.16 + clc 2.17 + 2.18 + ; Fill the room with empty space. 2.19 + 2.20 + ldx #78 2.21 + ldy #63 2.22 + make_empty_room_loop: 2.23 + lda #0 2.24 + sta $57a6,x 2.25 + dey 2.26 + tya 2.27 + and #7 2.28 + cmp #7 2.29 + bne finished_empty_room 2.30 + dex 2.31 + dex 2.32 + 2.33 +finished_empty_room: 2.34 + clc 2.35 + rts 2.36 + 2.37 +not_starting_room: 2.38 + clc 2.39 + 2.40 ; Fill in the room details. 2.41 2.42 lda $7f 2.43 @@ -270,14 +303,17 @@ 2.44 sbc $7e 2.45 sta $7d 2.46 clc 2.47 - ; Discard the first ten values. 2.48 + 2.49 + ; Discard the first ten values. 2.50 + 2.51 ldy #10 2.52 make_room_loop0: 2.53 jsr unlimited_values 2.54 dey 2.55 bne make_room_loop0 2.56 2.57 - ; Fill the room array with values. 2.58 + ; Fill the room array with values. 2.59 + 2.60 ldx #78 2.61 ldy #63 2.62 make_room_loop1: 2.63 @@ -394,9 +430,9 @@ 2.64 plot_room: ; $78,$79 = i,j (from $4ff0,$4ff1) 2.65 jsr blank_screen 2.66 2.67 - lda $4ff0 2.68 + lda $4ff2 2.69 sta $78 2.70 - lda $4ff1 2.71 + lda $4ff3 2.72 sta $79 2.73 2.74 lda #$00 2.75 @@ -615,30 +651,56 @@ 2.76 rts 2.77 2.78 2.79 -key_input: 2.80 - lda #129 2.81 - ldx #158 2.82 +check_key: ; x=key code 2.83 + lda #129 ; returns y=255 or 0 2.84 ldy #255 2.85 jsr $fff4 2.86 + rts 2.87 + 2.88 +key_input: ; returns A=0 (no key), 1 (left), 2 (right), 3 (up) 2.89 + ; 4 (down), 5 (fire) 2.90 + 2.91 + ldx #158 ; -98 (Z) 2.92 + jsr check_key 2.93 cpy #255 2.94 bne not_left_key 2.95 lda #1 2.96 - sta $74 2.97 - jmp exit_keys 2.98 -not_left_key: 2.99 - lda #129 2.100 - ldx #151 2.101 - ldy #255 2.102 - jsr $fff4 2.103 + rts 2.104 + 2.105 +not_left_key: 2.106 + ldx #189 ; -67 (X) 2.107 + jsr check_key 2.108 + cpy #255 2.109 + bne not_right_key 2.110 + lda #2 2.111 + rts 2.112 + 2.113 +not_right_key: 2.114 + ldx #183 ; -73 (:) 2.115 + jsr check_key 2.116 + cpy #255 2.117 + bne not_up_key 2.118 + lda #3 2.119 + rts 2.120 + 2.121 +not_up_key: 2.122 + ldx #151 ; -105 (/) 2.123 + jsr check_key 2.124 cpy #255 2.125 bne not_down_key 2.126 - lda #2 2.127 - sta $74 2.128 - jmp exit_keys 2.129 + lda #4 2.130 + rts 2.131 + 2.132 not_down_key: 2.133 + ldx #182 ; -74 (Return) 2.134 + jsr check_key 2.135 + cpy #255 2.136 + bne not_fire_key 2.137 + lda #5 2.138 + rts 2.139 + 2.140 +not_fire_key: 2.141 lda #0 2.142 - sta $74 2.143 -exit_keys: 2.144 rts 2.145 2.146 2.147 @@ -724,10 +786,12 @@ 2.148 rts 2.149 2.150 start_new_game: 2.151 - lda #5 2.152 + lda #5 ; set starting room and current room 2.153 sta $4ff0 2.154 + sta $4ff2 2.155 lda #5 2.156 sta $4ff1 2.157 + sta $4ff3 2.158 2.159 rts 2.160 2.161 @@ -745,9 +809,29 @@ 2.162 bne main_wait_loop 2.163 2.164 jsr start_new_game 2.165 - jsr plot_room 2.166 2.167 game_loop: 2.168 + lda $4ff2 2.169 + sta $78 2.170 + lda $4ff3 2.171 + sta $79 2.172 + jsr plot_room 2.173 + 2.174 + key_loop: 2.175 + jsr key_input 2.176 + cmp #1 2.177 + bne not_left 2.178 + sec 2.179 + lda $4ff3 2.180 + sbc #1 2.181 + sta $4ff3 2.182 + jmp after_key_loop 2.183 + 2.184 + not_left: 2.185 + jmp key_loop 2.186 + 2.187 + after_key_loop: 2.188 + jmp game_loop 2.189 2.190 jmp main_loop 2.191 rts
