junglejourney
changeset 106:ec9b8b735e5b
Started to add support for high scores.
| author | David Boddie <david@boddie.org.uk> |
|---|---|
| date | Sun Sep 04 02:49:24 2011 +0200 |
| parents | 5a0c9fedd2c2 |
| children | 249743a9dc47 |
| files | build.py mapcode.oph |
| diffstat | 2 files changed, 131 insertions(+), 28 deletions(-) [+] |
line diff
1.1 --- a/build.py Sun Sep 04 01:38:57 2011 +0200 1.2 +++ b/build.py Sun Sep 04 02:49:24 2011 +0200 1.3 @@ -47,6 +47,7 @@ 1.4 out_uef_file = sys.argv[1] 1.5 1.6 # Memory map 1.7 + # 1000 completion screen 1.8 # 1780 title screen 1.9 # 1F00 CODE 1.10 # 3?00 space 1.11 @@ -103,7 +104,8 @@ 1.12 # 1.13 # 4*2*0x30 + 4*0x30 + 4*2*0x10 + 5*4*2*0x40 + 4*0x40 + 4*0x40 + 4*0x40 + 5*0x40 + 2*0x60 + 2*0x60 + 0x3400 1.14 # 1.15 - # 5080 space 1.16 + # 5080 high scores 1.17 + # n 3 bytes score + 9 bytes ASCII 1.18 # 5100 objects/treasure table (121 entries) 1.19 # n type 1.20 #
2.1 --- a/mapcode.oph Sun Sep 04 01:38:57 2011 +0200 2.2 +++ b/mapcode.oph Sun Sep 04 02:49:24 2011 +0200 2.3 @@ -824,14 +824,7 @@ 2.4 sta $71 2.5 jsr set_palette 2.6 2.7 - lda #2 2.8 - sta $70 2.9 - sta $71 2.10 - jsr set_palette 2.11 - lda #3 2.12 - sta $70 2.13 - sta $71 2.14 - jsr set_palette 2.15 + jsr set_core_palette 2.16 rts 2.17 2.18 room_palettes: .byte 1, 6, 5, 7 2.19 @@ -3652,6 +3645,11 @@ 2.20 2.21 write_score: 2.22 2.23 + lda #$f6 2.24 + sta $70 2.25 + lda #$3d 2.26 + sta $71 2.27 + 2.28 ldx #2 2.29 write_score_vdu_bytes: 2.30 lda score_vdu_bytes,x 2.31 @@ -3659,10 +3657,7 @@ 2.32 dex 2.33 bpl write_score_vdu_bytes 2.34 2.35 - lda #$f6 2.36 - sta $70 2.37 - lda #$3d 2.38 - sta $71 2.39 +write_score_digits: ; $70,$71=address of score bytes 2.40 2.41 ldy #2 2.42 write_score_loop: 2.43 @@ -4134,6 +4129,20 @@ 2.44 2.45 rts 2.46 2.47 +copy_title_down: 2.48 + 2.49 + lda #$80 2.50 + sta $70 2.51 + lda #$61 2.52 + sta $71 2.53 + 2.54 + lda #$80 2.55 + sta $72 2.56 + lda #$1e 2.57 + sta $73 2.58 + 2.59 + ; Run on into the following routine. 2.60 + 2.61 copy_title: 2.62 2.63 ldx #7 2.64 @@ -4156,20 +4165,6 @@ 2.65 2.66 rts 2.67 2.68 -copy_title_down: 2.69 - 2.70 - lda #$80 2.71 - sta $70 2.72 - lda #$61 2.73 - sta $71 2.74 - 2.75 - lda #$80 2.76 - sta $72 2.77 - lda #$1e 2.78 - sta $73 2.79 - 2.80 - jmp copy_title ; optimise away the rts 2.81 - 2.82 copy_title_up: 2.83 2.84 lda #$80 2.85 @@ -4353,8 +4348,52 @@ 2.86 cmp #1 2.87 bne define_envelopes_loop 2.88 2.89 + ; Define the default high scores. 2.90 + ldy #0 2.91 + lda #$80 2.92 + sta $70 2.93 + lda #$50 2.94 + sta $71 2.95 + lda #$16 2.96 + sta $72 2.97 + 2.98 + init_define_high_scores_loop: 2.99 + 2.100 + lda #0 2.101 + sta ($70),y 2.102 + iny 2.103 + lda $72 2.104 + sta ($70),y 2.105 + iny 2.106 + lda #0 2.107 + sta ($70),y 2.108 + 2.109 + iny 2.110 + ldx #0 2.111 + init_define_high_score_name_loop: 2.112 + 2.113 + lda high_score_default_name,x 2.114 + sta ($70),y 2.115 + iny 2.116 + inx 2.117 + cpx #9 2.118 + bne init_define_high_score_name_loop 2.119 + 2.120 + sed 2.121 + lda $72 2.122 + sec 2.123 + sbc #2 2.124 + sta $72 2.125 + cld 2.126 + clc 2.127 + 2.128 + cpy #96 2.129 + bne init_define_high_scores_loop 2.130 + 2.131 rts 2.132 2.133 +high_score_default_name: .byte "- David -" 2.134 + 2.135 envelopes_low: .byte <explosion_envelope, <damage_envelope, <item_envelope 2.136 envelopes_high: .byte >explosion_envelope, >damage_envelope, >item_envelope 2.137 2.138 @@ -4429,6 +4468,60 @@ 2.139 ; Show the title. 2.140 jsr copy_title_up 2.141 2.142 + ; Show the high scores. 2.143 + 2.144 + lda #17 2.145 + jsr $ffee 2.146 + lda #3 2.147 + jsr $ffee 2.148 + 2.149 + lda #$80 2.150 + sta $70 2.151 + lda #$50 2.152 + sta $71 2.153 + 2.154 + lda #8 2.155 + sta $80 2.156 + 2.157 + show_title_high_scores_loop: 2.158 + 2.159 + lda #31 2.160 + jsr $ffee 2.161 + lda #2 2.162 + jsr $ffee 2.163 + lda $80 2.164 + adc #2 2.165 + sta $80 2.166 + clc 2.167 + jsr $ffee 2.168 + 2.169 + jsr write_score_digits 2.170 + 2.171 + lda #32 2.172 + jsr $ffee 2.173 + 2.174 + ldx #8 2.175 + ldy #3 2.176 + show_title_high_scores_vdu_loop2: 2.177 + 2.178 + lda ($70),y 2.179 + cmp #32 2.180 + bmi ignore_char 2.181 + cmp #123 2.182 + bpl ignore_char 2.183 + jsr $ffee 2.184 + 2.185 + ignore_char: 2.186 + iny 2.187 + dex 2.188 + bpl show_title_high_scores_vdu_loop2 2.189 + 2.190 + lda $70 2.191 + adc #12 2.192 + sta $70 2.193 + cmp #$e0 2.194 + bne show_title_high_scores_loop 2.195 + 2.196 lda #0 2.197 sta $72 2.198 2.199 @@ -4796,6 +4889,10 @@ 2.200 2.201 rts 2.202 2.203 +check_high_scores: 2.204 + 2.205 + rts 2.206 + 2.207 status_vdu_bytes: .byte 31,2,0, 17,3, "Score", 31,11,0, 17,2, "Strength", 17,1 2.208 ; TAB(1,0), COLOUR 3, "Score", TAB(12,0), COLOUR 2, "Strength", COLOUR 1 2.209 2.210 @@ -4819,7 +4916,7 @@ 2.211 bmi write_status_text_loop 2.212 2.213 ; Set the level. 2.214 - lda #3 2.215 + lda #0 2.216 sta $3dfa 2.217 2.218 ; Set the score. 2.219 @@ -4827,6 +4924,7 @@ 2.220 sta $3df6 2.221 sta $3df7 2.222 sta $3df8 2.223 + 2.224 jsr write_score 2.225 2.226 ; Set the player's strength. 2.227 @@ -5105,6 +5203,9 @@ 2.228 lda #12 2.229 jsr $ffee 2.230 2.231 + ; Check the score against the high scores. 2.232 + jsr check_high_scores 2.233 + 2.234 jmp main_loop 2.235 2.236 exit:
