junglejourney

changeset 103:7b24f56be115

Added an end of level screen. Updated the memory map.
author David Boddie <david@boddie.org.uk>
date Sat Sep 03 18:47:16 2011 +0200
parents 14783432fd79
children b9003a1a35e9
files TODO.txt build.py mapcode.oph
diffstat 3 files changed, 288 insertions(+), 18 deletions(-) [+]
line diff
     1.1 --- a/TODO.txt	Sat Sep 03 14:59:56 2011 +0200
     1.2 +++ b/TODO.txt	Sat Sep 03 18:47:16 2011 +0200
     1.3 @@ -1,8 +1,8 @@
     1.4  To Do
     1.5  
     1.6  Finish the title screen.
     1.7 -Add a screen to show between levels.
     1.8  Add a completion screen.
     1.9 +Make one of the enemies have different movement.
    1.10  Improve the fire, explosion and player sprites.
    1.11  Add sounds.
    1.12  Nice to have: make projectiles start next to the player, not on top of him.
     2.1 --- a/build.py	Sat Sep 03 14:59:56 2011 +0200
     2.2 +++ b/build.py	Sat Sep 03 18:47:16 2011 +0200
     2.3 @@ -73,8 +73,9 @@
     2.4      #   new characters are added after these
     2.5      #
     2.6      # 3D2A space
     2.7 -    # 3DF0 item/player flags (128=leave level, bits 4,5,6=enemy limit,
     2.8 -    #                         2=player demise, 1=has key)
     2.9 +    # 3DF0 item/player flags (128=leave level, 64=player demise,
    2.10 +    #                         bits 4,5,6=enemy limit, 2=complete game,
    2.11 +    #                         1=has key)
    2.12      # 3DF1 weapon/enemy limit (the highest weapon/enemy possible on a level)
    2.13      # 3DF2 current room (i, j)
    2.14      # 3DF4 lives (strength)
     3.1 --- a/mapcode.oph	Sat Sep 03 14:59:56 2011 +0200
     3.2 +++ b/mapcode.oph	Sat Sep 03 18:47:16 2011 +0200
     3.3 @@ -764,13 +764,16 @@
     3.4      lda $3df3
     3.5      sta $79
     3.6  
     3.7 +    jsr make_room
     3.8 +    ; Run on into the next piece of code.
     3.9 +
    3.10 +plot_room_tiles:
    3.11 +
    3.12      lda #$80
    3.13      sta $72
    3.14      lda #$5a
    3.15      sta $73         ; $72,$73 = screen position
    3.16  
    3.17 -    jsr make_room
    3.18 -
    3.19      lda #0
    3.20      sta $7a
    3.21      row_loop:
    3.22 @@ -2087,8 +2090,18 @@
    3.23  
    3.24  try_to_exit_level:
    3.25  
    3.26 -    lda $3df0                   ; set the exit flag
    3.27 +    cmp #6
    3.28 +    bmi just_exit_level
    3.29 +
    3.30 +    lda $3df0                   ; set the complete game flag
    3.31 +    ora #$02
    3.32 +    jmp try_to_exit_level_exit
    3.33 +
    3.34 +    just_exit_level:
    3.35 +    lda $3df0                   ; set the exit level flag
    3.36      ora #$80
    3.37 +
    3.38 +    try_to_exit_level_exit:
    3.39      sta $3df0
    3.40      sec                         ; indicate that the player is leaving the room
    3.41      rts
    3.42 @@ -3515,8 +3528,8 @@
    3.43      lda eleven_times_table,x
    3.44      adc $3df3
    3.45      tax
    3.46 -    lda #0
    3.47 -    sta $5100,x
    3.48 +    lda #$80    ; store a value with the top bit set instead of zero because we
    3.49 +    sta $5100,x ; have visited this room if we can collect the object within it
    3.50  
    3.51      lda #0      ; remove the item from the character list
    3.52      ldy #0
    3.53 @@ -3536,7 +3549,7 @@
    3.54      cmp #8
    3.55      bmi move_characters_not_health
    3.56  
    3.57 -    lda #12
    3.58 +    lda #20
    3.59      sta $70
    3.60      jsr add_strength
    3.61      clc
    3.62 @@ -4219,6 +4232,255 @@
    3.63  
    3.64      rts
    3.65  
    3.66 +end_of_level_bytes1:  .byte 31,1,3, 17,3, "Exploration bonus", 31,11,5, "x 5"
    3.67 +end_of_level_bytes2:  .byte 31,0,28, 17,2, "My journey continues"
    3.68 +
    3.69 +show_end_of_level_screen:
    3.70 +
    3.71 +    ; Draw a decorative room.
    3.72 +    ldx #99
    3.73 +    end_of_level_clear_room_loop:
    3.74 +
    3.75 +        lda #0
    3.76 +        sta $579c,x
    3.77 +        dex
    3.78 +        bpl end_of_level_clear_room_loop
    3.79 +
    3.80 +    ldx #5
    3.81 +    end_of_level_h_walls_loop:
    3.82 +
    3.83 +        lda #3
    3.84 +        sta $57b2,x
    3.85 +        sta $57e4,x
    3.86 +        dex
    3.87 +        bpl end_of_level_h_walls_loop
    3.88 +
    3.89 +    ldx #30
    3.90 +    end_of_level_v_walls_loop:
    3.91 +
    3.92 +        lda #3
    3.93 +        sta $57bc,x
    3.94 +        sta $57c1,x
    3.95 +        txa
    3.96 +        sec
    3.97 +        sbc #10
    3.98 +        tax
    3.99 +        bpl end_of_level_v_walls_loop
   3.100 +
   3.101 +    jsr plot_room_tiles
   3.102 +
   3.103 +    ldx #0
   3.104 +    end_of_level_text_loop1:
   3.105 +
   3.106 +        lda end_of_level_bytes1,x
   3.107 +        jsr $ffee
   3.108 +        inx
   3.109 +        cpx #28
   3.110 +        bne end_of_level_text_loop1
   3.111 +
   3.112 +    ; Count the number of rooms explored.
   3.113 +    ldx #0
   3.114 +    lda #0
   3.115 +    ldy #0
   3.116 +    sta $8d
   3.117 +    sta $8e
   3.118 +    end_of_level_room_count_loop:
   3.119 +
   3.120 +        lda $5100,x
   3.121 +        and #$80
   3.122 +        beq end_of_level_room_count_loop_next
   3.123 +
   3.124 +        sed
   3.125 +        lda $8d
   3.126 +        adc #1
   3.127 +        sta $8d
   3.128 +        lda $8e
   3.129 +        adc #0
   3.130 +        sta $8e
   3.131 +        cld
   3.132 +        clc
   3.133 +
   3.134 +        end_of_level_room_count_loop_next:
   3.135 +        inx
   3.136 +        cpx #121
   3.137 +        bne end_of_level_room_count_loop
   3.138 +
   3.139 +    ; Position the player so that we can perform an animation.
   3.140 +    lda #6      ; down (first frame)
   3.141 +    sta $3d01
   3.142 +    lda #4      ; y=4
   3.143 +    sta $3d02
   3.144 +    lda #3      ; dy=3
   3.145 +    sta $3d03
   3.146 +    lda #4      ; x=4
   3.147 +    sta $3d04
   3.148 +    lda #3      ; dx=3
   3.149 +    sta $3d05
   3.150 +
   3.151 +    jsr remove_characters
   3.152 +
   3.153 +    jsr reset_unplot_buffer
   3.154 +    jsr reset_plot_buffer
   3.155 +
   3.156 +    lda #$00        ; plot the player
   3.157 +    sta $74
   3.158 +    lda #$3d
   3.159 +    sta $75
   3.160 +    jsr plot_character
   3.161 +
   3.162 +    jsr plot_buffer
   3.163 +
   3.164 +    lda $8d
   3.165 +    sta $70
   3.166 +    lda $8e
   3.167 +    sta $71
   3.168 +    jsr write_bonus
   3.169 +
   3.170 +    lda #0      ; reset motion counter
   3.171 +    sta $3dfe
   3.172 +
   3.173 +    show_end_of_level_bonus_loop:
   3.174 +
   3.175 +        lda #19
   3.176 +        jsr $fff4
   3.177 +
   3.178 +        clc
   3.179 +        lda $3dfe
   3.180 +        and #15
   3.181 +        bne end_of_level_no_animation
   3.182 +
   3.183 +        ; Animate the player.
   3.184 +
   3.185 +        jsr reset_unplot_buffer
   3.186 +        jsr reset_plot_buffer
   3.187 +
   3.188 +        ; $74,$75 should be unchanged
   3.189 +        jsr unplot_character
   3.190 +
   3.191 +        lda $3d01
   3.192 +        eor #1
   3.193 +        sta $3d01
   3.194 +        jsr plot_character
   3.195 +
   3.196 +        jsr plot_buffer
   3.197 +
   3.198 +        end_of_level_no_animation:
   3.199 +        clc
   3.200 +        lda $3dfe
   3.201 +        and #3
   3.202 +        bne end_of_level_no_countdown
   3.203 +
   3.204 +        ; Transfer the bonus to the score.
   3.205 +
   3.206 +        sed
   3.207 +        sec
   3.208 +        lda $8d
   3.209 +        sbc #1
   3.210 +        sta $8d
   3.211 +        sta $70
   3.212 +        lda $8e
   3.213 +        sbc #0
   3.214 +        sta $8e
   3.215 +        sta $71
   3.216 +        cld
   3.217 +        clc
   3.218 +
   3.219 +        jsr write_bonus
   3.220 +
   3.221 +        lda #5
   3.222 +        sta $70
   3.223 +        jsr add_score
   3.224 +
   3.225 +        end_of_level_no_countdown:
   3.226 +        inc $3dfe   ; update motion counter
   3.227 +        clc
   3.228 +
   3.229 +        lda $8d
   3.230 +        cmp #0
   3.231 +        bne show_end_of_level_bonus_loop
   3.232 +
   3.233 +        lda $8e
   3.234 +        cmp #0
   3.235 +        bne show_end_of_level_bonus_loop
   3.236 +
   3.237 +    lda #64    ; initialise delay counter
   3.238 +    sta $3df5
   3.239 +
   3.240 +    show_end_of_level_delay_loop1:
   3.241 +
   3.242 +        lda #19
   3.243 +        jsr $fff4
   3.244 +
   3.245 +        dec $3df5
   3.246 +        bne show_end_of_level_delay_loop1
   3.247 +
   3.248 +    ldx #0
   3.249 +    end_of_level_text_loop2:
   3.250 +
   3.251 +        lda end_of_level_bytes2,x
   3.252 +        jsr $ffee
   3.253 +        inx
   3.254 +        cpx #25
   3.255 +        bne end_of_level_text_loop2
   3.256 +
   3.257 +    lda #192    ; initialise delay counter
   3.258 +    sta $3df5
   3.259 +
   3.260 +    show_end_of_level_delay_loop2:
   3.261 +
   3.262 +        lda #19
   3.263 +        jsr $fff4
   3.264 +
   3.265 +        dec $3df5
   3.266 +        bne show_end_of_level_delay_loop2
   3.267 +
   3.268 +    rts
   3.269 +
   3.270 +level_bonus_vdu_bytes: .byte 5,6,31, 1,17  ; reversed
   3.271 +
   3.272 +write_bonus:        ; $70,$71=value
   3.273 +                    ; $72,$73=address of VDU codes
   3.274 +
   3.275 +    ldx #4
   3.276 +    write_bonus_vdu_bytes:
   3.277 +
   3.278 +        lda level_bonus_vdu_bytes,x
   3.279 +        jsr $ffee
   3.280 +        dex
   3.281 +        bpl write_bonus_vdu_bytes
   3.282 +
   3.283 +    ldy #1
   3.284 +    write_bonus_loop:
   3.285 +
   3.286 +        tya
   3.287 +        tax         ; temporary
   3.288 +
   3.289 +        lda $70,x
   3.290 +        sta $80
   3.291 +        lsr
   3.292 +        lsr
   3.293 +        lsr
   3.294 +        lsr
   3.295 +        tax
   3.296 +        lda score_digits,x
   3.297 +        jsr $ffee
   3.298 +
   3.299 +        lda $80
   3.300 +        and #$0f
   3.301 +        tax
   3.302 +        lda score_digits,x
   3.303 +        jsr $ffee
   3.304 +
   3.305 +        dey
   3.306 +        bpl write_bonus_loop
   3.307 +
   3.308 +    clc
   3.309 +    rts
   3.310 +
   3.311 +show_complete_game:
   3.312 +
   3.313 +    rts
   3.314 +
   3.315  status_vdu_bytes: .byte 31,2,0, 17,3, "Score", 31,11,0, 17,2, "Strength", 17,1
   3.316  ; TAB(1,0), COLOUR 3, "Score", TAB(12,0), COLOUR 2, "Strength", COLOUR 1
   3.317  
   3.318 @@ -4269,11 +4531,6 @@
   3.319      lda #0
   3.320      sta $3df0
   3.321  
   3.322 -    ; Add to the player's strength.
   3.323 -    lda #20
   3.324 -    sta $70
   3.325 -    jsr add_strength
   3.326 -
   3.327      ; Set current room.
   3.328  
   3.329      ldx $3dfa
   3.330 @@ -4288,13 +4545,13 @@
   3.331      sta $3d00
   3.332      lda #6      ; down (first frame)
   3.333      sta $3d01
   3.334 -    lda #5      ; y=5
   3.335 +    lda #4      ; y=4
   3.336      sta $3d02
   3.337 -    lda #0      ; dy=0
   3.338 +    lda #3      ; dy=3
   3.339      sta $3d03
   3.340 -    lda #5      ; x=5
   3.341 +    lda #4      ; x=4
   3.342      sta $3d04
   3.343 -    lda #0      ; dx=0
   3.344 +    lda #3      ; dx=3
   3.345      sta $3d05
   3.346  
   3.347      ; Fill the treasure table with objects.
   3.348 @@ -4507,14 +4764,26 @@
   3.349                  and #$40
   3.350                  bne game_over
   3.351  
   3.352 +                lda $3df0
   3.353 +                and #$02
   3.354 +                bne complete_game
   3.355 +
   3.356                  jmp game_loop
   3.357  
   3.358              exit_level:
   3.359 +
   3.360 +            jsr show_end_of_level_screen
   3.361 +
   3.362              inc $3dfa
   3.363              jmp level_loop
   3.364  
   3.365              game_over:
   3.366              jsr show_game_over
   3.367 +            jmp main_loop
   3.368 +
   3.369 +            complete_game:
   3.370 +            jsr show_complete_game
   3.371 +            jmp main_loop
   3.372  
   3.373          jmp main_loop
   3.374