junglejourney
changeset 115:2f8c43559970
Reimplemented the text character printing routine.
Removed redundant code.
| author | David Boddie <david@boddie.org.uk> |
|---|---|
| date | Mon Sep 05 22:42:28 2011 +0200 |
| parents | 81dd2318a0a4 |
| children | 101d8474c62d |
| files | mapcode.oph |
| diffstat | 1 files changed, 131 insertions(+), 92 deletions(-) [+] |
line diff
1.1 --- a/mapcode.oph Mon Sep 05 00:04:11 2011 +0200 1.2 +++ b/mapcode.oph Mon Sep 05 22:42:28 2011 +0200 1.3 @@ -792,9 +792,7 @@ 1.4 sta $7b 1.5 jsr plot_tile 1.6 1.7 - lda $7a 1.8 - adc #1 1.9 - sta $7a 1.10 + inc $7a 1.11 lda $76 1.12 sec 1.13 sbc #1 1.14 @@ -1833,9 +1831,7 @@ 1.15 1.16 move_player_leave_room_right: 1.17 clc 1.18 - lda $3df3 1.19 - adc #1 1.20 - sta $3df3 1.21 + inc $3df3 1.22 clc 1.23 1.24 ; Set the player's position on the left of the screen. 1.25 @@ -2018,10 +2014,7 @@ 1.26 jmp animate_player_down ; optimise away the rts 1.27 1.28 move_player_leave_room_down: 1.29 - clc 1.30 - lda $3df2 1.31 - adc #1 1.32 - sta $3df2 1.33 + inc $3df2 1.34 clc 1.35 1.36 ; Set the player's position on the top of the screen. 1.37 @@ -3788,8 +3781,22 @@ 1.38 sta ($74),y 1.39 1.40 jsr plot_character 1.41 + jmp reduce_strength_not_emerging_enemy 1.42 1.43 reduce_strength_not_enemy: 1.44 + cmp #3 1.45 + bne reduce_strength_not_emerging_enemy 1.46 + 1.47 + jsr unplot_character 1.48 + 1.49 + iny ; whether emerging or exploding, ensure that the enemy 1.50 + lda ($74),y ; is now exploding 1.51 + ora #8 1.52 + sta ($74),y 1.53 + 1.54 + jsr plot_character 1.55 + 1.56 + reduce_strength_not_emerging_enemy: 1.57 clc 1.58 lda $74 1.59 adc #6 1.60 @@ -4028,24 +4035,6 @@ 1.61 clc 1.62 rts 1.63 1.64 -set_palette: 1.65 - ; $70=logical colour 1.66 - ; $71=physical colour 1.67 - lda $70 1.68 - sta $3dfb 1.69 - lda $71 1.70 - sta $3dfc 1.71 - lda #0 1.72 - sta $3dfd 1.73 - sta $3dfe 1.74 - sta $3dff 1.75 - 1.76 - lda #$c 1.77 - ldx #$fb 1.78 - ldy #$3d 1.79 - jsr $fff1 1.80 - rts 1.81 - 1.82 blank_screen: 1.83 lda #1 1.84 sta $70 1.85 @@ -4061,7 +4050,24 @@ 1.86 sta $70 1.87 lda #0 1.88 sta $71 1.89 - jsr set_palette 1.90 + ; Run on into set_palette. 1.91 + 1.92 +set_palette: 1.93 + ; $70=logical colour 1.94 + ; $71=physical colour 1.95 + lda $70 1.96 + sta $3dfb 1.97 + lda $71 1.98 + sta $3dfc 1.99 + lda #0 1.100 + sta $3dfd 1.101 + sta $3dfe 1.102 + sta $3dff 1.103 + 1.104 + lda #$c 1.105 + ldx #$fb 1.106 + ldy #$3d 1.107 + jsr $fff1 1.108 rts 1.109 1.110 sounds_low: .byte <explosion_sound, <damage_sound, <item_sound, <key_sound 1.111 @@ -4431,7 +4437,7 @@ 1.112 lda #19 1.113 jmp $fff4 ; optimise away the rts 1.114 1.115 -game_over_vdu_bytes: .byte 31,4,15, 17,2, "The journey", 31,7,16, "is over" 1.116 +game_over_vdu_bytes: .byte 31,4,15, 17,2, "The journey", 31,7,17, "is over" 1.117 1.118 show_game_over: 1.119 1.120 @@ -4856,76 +4862,67 @@ 1.121 jsr plot_room_tiles 1.122 1.123 ; Add text characters to the room. 1.124 - 1.125 - lda #5 1.126 + lda #17 1.127 jsr $ffee 1.128 - 1.129 - lda #160 ; x (low) 1.130 + lda #3 1.131 + jsr $ffee 1.132 + 1.133 + lda #3 ; x 1.134 sta $70 1.135 - lda #0 ; x (high) 1.136 + lda #6 ; y 1.137 sta $71 1.138 1.139 - lda #$40 ; y (low) 1.140 + lda #65 1.141 sta $72 1.142 - lda #$03 ; y (high) 1.143 - sta $73 1.144 - 1.145 - lda #65 1.146 - sta $74 1.147 - 1.148 + 1.149 + ldx #5 1.150 + ldy #0 1.151 plot_text_characters_loop: 1.152 1.153 - lda #25 1.154 - jsr $ffee 1.155 - lda #4 1.156 - jsr $ffee 1.157 - 1.158 - ldx #0 1.159 - move_xy_loop: 1.160 - 1.161 - lda $70,x 1.162 - jsr $ffee 1.163 - inx 1.164 - cpx #5 1.165 - bne move_xy_loop 1.166 - 1.167 - cmp #90 1.168 - bpl plot_text_characters_endloop 1.169 - 1.170 - inc $74 1.171 - 1.172 + cpy #14 1.173 + beq skip_space 1.174 + cpy #15 1.175 + beq skip_space 1.176 + 1.177 + jsr print_xy 1.178 + inc $72 1.179 + 1.180 + skip_space: 1.181 + clc 1.182 + 1.183 + plot_text_characters_next1: 1.184 + lda $71 1.185 + adc #4 1.186 + sta $71 1.187 + 1.188 + dex 1.189 + bpl plot_text_characters_next2 1.190 + 1.191 + lda #6 1.192 + sta $71 1.193 lda $70 1.194 - adc #128 1.195 + adc #3 1.196 sta $70 1.197 - lda $71 1.198 - adc #0 1.199 - sta $71 1.200 - clc 1.201 - 1.202 - cmp #$04 1.203 + 1.204 + ldx #5 1.205 + 1.206 + plot_text_characters_next2: 1.207 + 1.208 + iny 1.209 + lda $72 1.210 + cmp #91 1.211 bne plot_text_characters_loop 1.212 - lda $70 1.213 - cmp #$20 1.214 - bne plot_text_characters_loop 1.215 - 1.216 - lda #160 1.217 - sta $70 1.218 - lda #0 1.219 - sta $71 1.220 - 1.221 - lda $72 1.222 - sec 1.223 - sbc #192 1.224 - sta $72 1.225 - lda $73 1.226 - sbc #0 1.227 - sta $73 1.228 - clc 1.229 - 1.230 - jmp plot_text_characters_loop 1.231 - 1.232 - plot_text_characters_endloop: 1.233 - clc 1.234 + 1.235 + lda #95 ; _ representing a space 1.236 + sta $72 1.237 + jsr print_xy 1.238 + 1.239 + lda $71 1.240 + adc #4 1.241 + sta $71 1.242 + lda #60 ; < representing delete 1.243 + sta $72 1.244 + jsr print_xy 1.245 1.246 ; Put the player in the centre of the room. 1.247 jsr position_player_set_up_plotting 1.248 @@ -4939,6 +4936,9 @@ 1.249 lda #0 ; reset the level number so that the correct tiles are used 1.250 sta $3dfa 1.251 1.252 + lda #3 ; cursor position in the high score entry held in $8d,$8e 1.253 + sta $8f 1.254 + 1.255 jsr set_standard_palette 1.256 1.257 high_score_entry_loop: 1.258 @@ -4949,8 +4949,35 @@ 1.259 jsr move_player 1.260 bcs high_score_entry_after_loop ; check if the player leaves the room 1.261 1.262 - lda #19 1.263 - jsr $fff4 1.264 + lda $3302 ; y 1.265 + asl 1.266 + and #7 1.267 + cmp $3303 ; dy 1.268 + bne high_score_entry_not_aligned 1.269 + 1.270 + lda $3305 ; dx 1.271 + tax 1.272 + and #1 1.273 + bne high_score_entry_not_aligned 1.274 + txa 1.275 + adc $3304 ; x 1.276 + 1.277 + cmp #3 1.278 + beq high_score_entry_aligned 1.279 + cmp #6 1.280 + beq high_score_entry_aligned 1.281 + cmp #9 1.282 + bne high_score_entry_not_aligned 1.283 + 1.284 + high_score_entry_aligned: 1.285 + 1.286 + 1.287 + 1.288 + ; The player is aligned with a letter. 1.289 + 1.290 + high_score_entry_not_aligned: 1.291 + 1.292 + jsr wait_for_vsync 1.293 jsr plot_buffer 1.294 1.295 jmp high_score_entry_loop 1.296 @@ -4964,6 +4991,18 @@ 1.297 1.298 rts 1.299 1.300 +print_xy: 1.301 + 1.302 + lda #31 1.303 + jsr $ffee 1.304 + lda $70 1.305 + jsr $ffee 1.306 + lda $71 1.307 + jsr $ffee 1.308 + lda $72 1.309 + jsr $ffee 1.310 + rts 1.311 + 1.312 status_vdu_bytes: .byte 31,2,0, 17,3, "Score", 31,11,0, 17,2, "Strength", 17,1 1.313 ; TAB(1,0), COLOUR 3, "Score", TAB(12,0), COLOUR 2, "Strength", COLOUR 1 1.314
