junglejourney

changeset 129:2b2356e96c0f

Moved global variables to make more space for code.
author David Boddie <david@boddie.org.uk>
date Sat Sep 10 13:52:24 2011 +0200
parents d27c644bec24
children ae6589e0aeca
files build.py mapcode.oph
diffstat 2 files changed, 133 insertions(+), 133 deletions(-) [+]
line diff
     1.1 --- a/build.py	Sat Sep 10 13:27:54 2011 +0200
     1.2 +++ b/build.py	Sat Sep 10 13:52:24 2011 +0200
     1.3 @@ -53,21 +53,6 @@
     1.4      # 1780 title screen
     1.5      # 1F00 CODE
     1.6      #
     1.7 -    # 3DF0 item/player flags (128=leave level, 64=player demise,
     1.8 -    #                         bits 4,5,6=enemy limit, 2=complete game,
     1.9 -    #                         1=has key)
    1.10 -    # 3DF1 weapon/enemy limit (the highest weapon/enemy possible on a level)
    1.11 -    # 3DF2 current room (i, j)
    1.12 -    # 3DF4 lives (strength)
    1.13 -    # 3DF5 delay counter
    1.14 -    # 3DF6 score (three bytes)
    1.15 -    # 3DF9 projectile type
    1.16 -    # 3DFA level
    1.17 -    # 3DFB palette workspace (enough for one 5 byte palette entry)
    1.18 -    #       3DFD is also projectile counter when in a room
    1.19 -    #       3DFE is also motion counter when in a room
    1.20 -    #       3DFF is also enemy generation counter when in a room
    1.21 -    #
    1.22      # 3E00 CHARS (character sprites)
    1.23      #       4 * 2 * 0x30 (player movement)
    1.24      #           4 * 0x30 (player demise)
    1.25 @@ -125,7 +110,22 @@
    1.26      #   3 * (1 * 0x60 (flowers)
    1.27      #        1 * 0x60 (tree)
    1.28      #        1 * 0x60 (tree))
    1.29 -    # 5780 space
    1.30 +    #
    1.31 +    # 5780 item/player flags (128=leave level, 64=player demise,
    1.32 +    #                         bits 4,5,6=enemy limit, 2=complete game,
    1.33 +    #                         1=has key)
    1.34 +    # 5781 weapon/enemy limit (the highest weapon/enemy possible on a level)
    1.35 +    # 5782 current room (i, j)
    1.36 +    # 5784 lives (strength)
    1.37 +    # 5785 delay counter
    1.38 +    # 5786 score (three bytes)
    1.39 +    # 5789 projectile type
    1.40 +    # 578A level
    1.41 +    # 578B palette workspace (enough for one 5 byte palette entry)
    1.42 +    #       578D is also projectile counter when in a room
    1.43 +    #       578E is also motion counter when in a room
    1.44 +    #       578F is also enemy generation counter when in a room
    1.45 +    #
    1.46      # 579C room data (generated)
    1.47      #   0 blank
    1.48      #   1 flowers/decoration
     2.1 --- a/mapcode.oph	Sat Sep 10 13:27:54 2011 +0200
     2.2 +++ b/mapcode.oph	Sat Sep 10 13:52:24 2011 +0200
     2.3 @@ -324,7 +324,7 @@
     2.4  
     2.5      ; Add the final exit.
     2.6  
     2.7 -    lda $3dfa
     2.8 +    lda $578a
     2.9      cmp #3
    2.10      bmi make_room_no_final_exit
    2.11  
    2.12 @@ -345,7 +345,7 @@
    2.13  
    2.14      ; Make sure that the starting, exit, key rooms are empty.
    2.15  
    2.16 -    ldx $3dfa               ; level number
    2.17 +    ldx $578a               ; level number
    2.18      lda start_rooms_y,x
    2.19      cmp $78
    2.20      bne make_room_not_starting_room
    2.21 @@ -373,7 +373,7 @@
    2.22      tax
    2.23      lda exit_room_offsets,x
    2.24      tax
    2.25 -    lda $3df0
    2.26 +    lda $5780
    2.27      and #1
    2.28      beq exit_not_open
    2.29  
    2.30 @@ -411,7 +411,7 @@
    2.31      adc $79
    2.32      sta $7c
    2.33      sec
    2.34 -    ldx $3dfa
    2.35 +    ldx $578a
    2.36      lda seeds,x
    2.37      sbc $78
    2.38      sec
    2.39 @@ -821,7 +821,7 @@
    2.40      bpl plot_not_blank_after_add_loop   ; don't adjust the tile for later levels
    2.41      
    2.42      clc
    2.43 -    lda $3dfa
    2.44 +    lda $578a
    2.45      and #3              ; change the tile set for later levels
    2.46      tax
    2.47  
    2.48 @@ -853,12 +853,12 @@
    2.49      jsr plot
    2.50      rts
    2.51  
    2.52 -plot_room:          ; $78,$79 = i,j (from $3df2,$3df3)
    2.53 +plot_room:          ; $78,$79 = i,j (from $5782,$5783)
    2.54      jsr blank_screen
    2.55  
    2.56 -    lda $3df2
    2.57 +    lda $5782
    2.58      sta $78
    2.59 -    lda $3df3
    2.60 +    lda $5783
    2.61      sta $79
    2.62  
    2.63      jsr make_room
    2.64 @@ -1737,7 +1737,7 @@
    2.65  
    2.66  move_player:
    2.67  
    2.68 -    lda $3dfe
    2.69 +    lda $578e
    2.70      and #1
    2.71      beq move_player_allowed
    2.72  
    2.73 @@ -1823,9 +1823,9 @@
    2.74  
    2.75      move_player_leave_room_left:
    2.76      sec
    2.77 -    lda $3df3
    2.78 +    lda $5783
    2.79      sbc #1
    2.80 -    sta $3df3
    2.81 +    sta $5783
    2.82      clc
    2.83  
    2.84      ; Set the player's position on the right of the screen.
    2.85 @@ -1924,7 +1924,7 @@
    2.86  
    2.87      move_player_leave_room_right:
    2.88      clc
    2.89 -    inc $3df3
    2.90 +    inc $5783
    2.91      clc
    2.92  
    2.93      ; Set the player's position on the left of the screen.
    2.94 @@ -2010,9 +2010,9 @@
    2.95  
    2.96      move_player_leave_room_up:
    2.97      sec
    2.98 -    lda $3df2
    2.99 +    lda $5782
   2.100      sbc #1
   2.101 -    sta $3df2
   2.102 +    sta $5782
   2.103      clc
   2.104  
   2.105      ; Set the player's position on the bottom of the screen.
   2.106 @@ -2107,7 +2107,7 @@
   2.107      jmp animate_player_down     ; optimise away the rts
   2.108  
   2.109      move_player_leave_room_down:
   2.110 -    inc $3df2
   2.111 +    inc $5782
   2.112      clc
   2.113  
   2.114      ; Set the player's position on the top of the screen.
   2.115 @@ -2132,22 +2132,22 @@
   2.116      cmp #6
   2.117      bmi just_exit_level
   2.118  
   2.119 -    lda $3df0                   ; set the complete game flag
   2.120 +    lda $5780                   ; set the complete game flag
   2.121      ora #$02
   2.122      jmp try_to_exit_level_exit
   2.123  
   2.124      just_exit_level:
   2.125 -    lda $3df0                   ; set the exit level flag
   2.126 +    lda $5780                   ; set the exit level flag
   2.127      ora #$80
   2.128  
   2.129      try_to_exit_level_exit:
   2.130 -    sta $3df0
   2.131 +    sta $5780
   2.132      sec                         ; indicate that the player is leaving the room
   2.133      rts
   2.134  
   2.135  check_fire_key:
   2.136  
   2.137 -    lda $3dfd
   2.138 +    lda $578d
   2.139      bne check_fire_key_exit
   2.140  
   2.141      ldx #182            ; (Return)
   2.142 @@ -2160,7 +2160,7 @@
   2.143      bne check_fire_key_exit
   2.144  
   2.145      lda #15
   2.146 -    sta $3dfd
   2.147 +    sta $578d
   2.148  
   2.149      jmp create_projectile   ; optimise away the rts
   2.150  
   2.151 @@ -2178,7 +2178,7 @@
   2.152      asl
   2.153      asl
   2.154      asl
   2.155 -    ora $3df9       ; apply the projectile type
   2.156 +    ora $5789       ; apply the projectile type
   2.157      sta $5187
   2.158  
   2.159      lda $5183       ; dy
   2.160 @@ -2229,11 +2229,11 @@
   2.161      clc
   2.162  
   2.163      emerge_type_ok:
   2.164 -    cmp $3df1               ; only allow the appropriate enemies for this level
   2.165 +    cmp $5781               ; only allow the appropriate enemies for this level
   2.166      bmi emerge_type_exit
   2.167  
   2.168      sec
   2.169 -    sbc $3df1
   2.170 +    sbc $5781
   2.171      clc
   2.172  
   2.173      emerge_type_exit:
   2.174 @@ -2247,7 +2247,7 @@
   2.175  emerge_character:           ; $74,$75=character address
   2.176  
   2.177      lda #63
   2.178 -    sta $3dff
   2.179 +    sta $578f
   2.180  
   2.181      jsr unlimited_values
   2.182      and #$0f
   2.183 @@ -2907,7 +2907,7 @@
   2.184      jsr play_sound
   2.185  
   2.186      lda #15                     ; prevent the player from firing a new
   2.187 -    sta $3dfd                   ; projectile until the explosion has finished
   2.188 +    sta $578d                   ; projectile until the explosion has finished
   2.189  
   2.190      move_projectile_left_exit:
   2.191      sec
   2.192 @@ -3030,7 +3030,7 @@
   2.193      jsr play_sound
   2.194  
   2.195      lda #15                     ; prevent the player from firing a new
   2.196 -    sta $3dfd                   ; projectile until the explosion has finished
   2.197 +    sta $578d                   ; projectile until the explosion has finished
   2.198  
   2.199      move_projectile_right_exit:
   2.200      sec
   2.201 @@ -3139,7 +3139,7 @@
   2.202      jsr play_sound
   2.203  
   2.204      lda #15                     ; prevent the player from firing a new
   2.205 -    sta $3dfd                   ; projectile until the explosion has finished
   2.206 +    sta $578d                   ; projectile until the explosion has finished
   2.207  
   2.208      move_projectile_up_exit:
   2.209      sec
   2.210 @@ -3258,7 +3258,7 @@
   2.211      jsr play_sound
   2.212  
   2.213      lda #15                     ; prevent the player from firing a new
   2.214 -    sta $3dfd                   ; projectile until the explosion has finished
   2.215 +    sta $578d                   ; projectile until the explosion has finished
   2.216  
   2.217      move_projectile_down_exit:
   2.218      sec
   2.219 @@ -3449,7 +3449,7 @@
   2.220      lda #$51
   2.221      sta $75
   2.222  
   2.223 -    lda $3dfe           ; read a value from 0 to 3 from the motion counter
   2.224 +    lda $578e           ; read a value from 0 to 3 from the motion counter
   2.225      and #3
   2.226      tax
   2.227      lda enemy_slots,x   ; look up the corresponding slot in the character list
   2.228 @@ -3505,9 +3505,9 @@
   2.229      jsr unplot_character
   2.230  
   2.231      ; Remove it from the item table.
   2.232 -    ldx $3df2
   2.233 +    ldx $5782
   2.234      lda eleven_times_table,x
   2.235 -    adc $3df3
   2.236 +    adc $5783
   2.237      tax
   2.238      lda #$80    ; store a value with the top bit set instead of zero because we
   2.239      sta $5100,x ; have visited this room if we can collect the object within it
   2.240 @@ -3555,9 +3555,9 @@
   2.241      bmi move_characters_not_key
   2.242  
   2.243      ; Key - update the item/player flags byte.
   2.244 -    lda $3df0
   2.245 +    lda $5780
   2.246      ora #$01
   2.247 -    sta $3df0
   2.248 +    sta $5780
   2.249      clc
   2.250  
   2.251      ldx #3
   2.252 @@ -3569,7 +3569,7 @@
   2.253  
   2.254      ; Update the player's weapon.
   2.255      asl
   2.256 -    sta $3df9
   2.257 +    sta $5789
   2.258      clc
   2.259  
   2.260      ldx #2
   2.261 @@ -3613,22 +3613,22 @@
   2.262  add_score:      ; $70=score to add
   2.263  
   2.264      sed
   2.265 -    lda $3df6
   2.266 +    lda $5786
   2.267      adc $70
   2.268 -    sta $3df6
   2.269 -    lda $3df7
   2.270 +    sta $5786
   2.271 +    lda $5787
   2.272      adc #0
   2.273 -    sta $3df7
   2.274 -    lda $3df8
   2.275 +    sta $5787
   2.276 +    lda $5788
   2.277      adc #0
   2.278 -    sta $3df8
   2.279 +    sta $5788
   2.280      cld
   2.281  
   2.282  write_score:
   2.283  
   2.284 -    lda #$f6
   2.285 +    lda #$86
   2.286      sta $70
   2.287 -    lda #$3d
   2.288 +    lda #$57
   2.289      sta $71
   2.290  
   2.291      ldx #2
   2.292 @@ -3671,14 +3671,14 @@
   2.293      ; Divide the initial strength by 4 to determine which half character to
   2.294      ; start plotting at, and multiply by 8 to get the address. The net result
   2.295      ; is to mask off the bottom two bits and shift left once.
   2.296 -    lda $3df4
   2.297 +    lda $5784
   2.298      and #$fc
   2.299      sta $71     ; strength rounded down to a multiple of four units
   2.300      asl
   2.301      clc
   2.302      tay
   2.303  
   2.304 -    lda $3df4
   2.305 +    lda $5784
   2.306      adc $70
   2.307      cmp #65
   2.308      bmi add_strength_update
   2.309 @@ -3687,7 +3687,7 @@
   2.310  
   2.311      add_strength_update:
   2.312      clc
   2.313 -    sta $3df4   ; the final strength
   2.314 +    sta $5784   ; the final strength
   2.315  
   2.316      sec
   2.317      sbc $71
   2.318 @@ -3728,7 +3728,7 @@
   2.319  
   2.320      ; For any remaining units in excess of the multiples of four units, plot
   2.321      ; the appropriate byte.
   2.322 -    lda $3df4
   2.323 +    lda $5784
   2.324      and #3
   2.325      tax
   2.326  
   2.327 @@ -3741,7 +3741,7 @@
   2.328  
   2.329  reduce_strength:    ; $70=strength to remove
   2.330  
   2.331 -    lda $3df4
   2.332 +    lda $5784
   2.333      tax
   2.334      sec
   2.335      sbc $70
   2.336 @@ -3751,7 +3751,7 @@
   2.337  
   2.338      reduce_strength_update:
   2.339      clc
   2.340 -    sta $3df4
   2.341 +    sta $5784
   2.342  
   2.343      ; Divide the final strength by 4 to determine which half character to
   2.344      ; plot, and multiply by 8 to get the address. The net result is to mask off
   2.345 @@ -3765,22 +3765,22 @@
   2.346      lda #$59
   2.347      sta $71
   2.348  
   2.349 -    lda $3df4
   2.350 +    lda $5784
   2.351      and #3
   2.352      tax
   2.353      lda strength_units,x
   2.354      sta ($70),y
   2.355  
   2.356 -    lda $3df4
   2.357 +    lda $5784
   2.358      cmp #0
   2.359      bne reduce_strength_exit
   2.360  
   2.361 -    lda $3df0       ; the player ran out of strength
   2.362 +    lda $5780       ; the player ran out of strength
   2.363      ora #$40
   2.364 -    sta $3df0
   2.365 +    sta $5780
   2.366  
   2.367      lda #64         ; reset the delay counter
   2.368 -    sta $3df5
   2.369 +    sta $5785
   2.370  
   2.371      lda #$80        ; unplot the player
   2.372      sta $74
   2.373 @@ -4090,17 +4090,17 @@
   2.374                      ; $70=logical colour
   2.375                      ; $71=physical colour
   2.376      lda $70
   2.377 -    sta $3dfb
   2.378 +    sta $578b
   2.379      lda $71
   2.380 -    sta $3dfc
   2.381 +    sta $578c
   2.382      lda #0
   2.383 -    sta $3dfd
   2.384 -    sta $3dfe
   2.385 -    sta $3dff
   2.386 +    sta $578d
   2.387 +    sta $578e
   2.388 +    sta $578f
   2.389  
   2.390      lda #$c         
   2.391 -    ldx #$fb
   2.392 -    ldy #$3d
   2.393 +    ldx #$8b
   2.394 +    ldy #$57
   2.395      jsr $fff1
   2.396      rts
   2.397  
   2.398 @@ -4435,7 +4435,7 @@
   2.399      show_title_wait_loop:
   2.400  
   2.401          lda #150
   2.402 -        sta $3df5
   2.403 +        sta $5785
   2.404  
   2.405          ldx $72
   2.406          ldy #22
   2.407 @@ -4461,7 +4461,7 @@
   2.408          show_title_wait_inner_loop:
   2.409          jsr wait_for_vsync
   2.410  
   2.411 -        dec $3df5
   2.412 +        dec $5785
   2.413          beq show_title_wait_loop
   2.414  
   2.415          show_title_wait_loop_no_update:
   2.416 @@ -4490,11 +4490,11 @@
   2.417          bmi write_game_over_text_loop
   2.418  
   2.419      lda #192
   2.420 -    sta $3df5
   2.421 +    sta $5785
   2.422      show_game_over_delay_loop:
   2.423  
   2.424          jsr wait_for_vsync
   2.425 -        dec $3df5
   2.426 +        dec $5785
   2.427          bne show_game_over_delay_loop
   2.428  
   2.429      rts
   2.430 @@ -4577,14 +4577,14 @@
   2.431      jsr write_bonus
   2.432  
   2.433      lda #0      ; reset motion counter
   2.434 -    sta $3dfe
   2.435 +    sta $578e
   2.436  
   2.437      show_end_of_level_bonus_loop:
   2.438  
   2.439          jsr wait_for_vsync
   2.440  
   2.441          clc
   2.442 -        lda $3dfe
   2.443 +        lda $578e
   2.444          and #15
   2.445          bne end_of_level_no_animation
   2.446  
   2.447 @@ -4605,7 +4605,7 @@
   2.448  
   2.449          end_of_level_no_animation:
   2.450          clc
   2.451 -        lda $3dfe
   2.452 +        lda $578e
   2.453          and #3
   2.454          bne end_of_level_no_countdown
   2.455  
   2.456 @@ -4631,7 +4631,7 @@
   2.457          jsr add_score
   2.458  
   2.459          end_of_level_no_countdown:
   2.460 -        inc $3dfe   ; update motion counter
   2.461 +        inc $578e   ; update motion counter
   2.462          clc
   2.463  
   2.464          lda $8d
   2.465 @@ -4643,13 +4643,13 @@
   2.466          bne show_end_of_level_bonus_loop
   2.467  
   2.468      lda #64    ; initialise delay counter
   2.469 -    sta $3df5
   2.470 +    sta $5785
   2.471  
   2.472      show_end_of_level_delay_loop1:
   2.473  
   2.474          jsr wait_for_vsync
   2.475  
   2.476 -        dec $3df5
   2.477 +        dec $5785
   2.478          bne show_end_of_level_delay_loop1
   2.479  
   2.480      ldx #0
   2.481 @@ -4661,18 +4661,18 @@
   2.482          cpx #25
   2.483          bne end_of_level_text_loop2
   2.484  
   2.485 -    lda $3dfa
   2.486 +    lda $578a
   2.487      cmp #3
   2.488      bpl show_end_of_level_screen_exit
   2.489  
   2.490      lda #192    ; initialise delay counter
   2.491 -    sta $3df5
   2.492 +    sta $5785
   2.493  
   2.494      show_end_of_level_delay_loop2:
   2.495  
   2.496          jsr wait_for_vsync
   2.497  
   2.498 -        dec $3df5
   2.499 +        dec $5785
   2.500          bne show_end_of_level_delay_loop2
   2.501  
   2.502      show_end_of_level_screen_exit:
   2.503 @@ -4764,13 +4764,13 @@
   2.504      jsr set_complete_palette
   2.505  
   2.506      lda #255
   2.507 -    sta $3df5
   2.508 +    sta $5785
   2.509  
   2.510      show_complete_game_delay_loop:
   2.511  
   2.512          jsr wait_for_vsync
   2.513  
   2.514 -        dec $3df5
   2.515 +        dec $5785
   2.516          bne show_complete_game_no_message
   2.517  
   2.518          ldx #0
   2.519 @@ -4795,9 +4795,9 @@
   2.520      ; Start at the bottom of the table, moving scores down as necessary, and
   2.521      ; write in the current score at the appropriate place.
   2.522  
   2.523 -    lda #$f6    ; current score
   2.524 +    lda #$86    ; current score
   2.525      sta $70
   2.526 -    lda #$3d
   2.527 +    lda #$57
   2.528      sta $71
   2.529  
   2.530      lda #$80
   2.531 @@ -4961,13 +4961,13 @@
   2.532      jsr position_player_set_up_plotting
   2.533  
   2.534      lda #0          ; reset motion counter
   2.535 -    sta $3dfe
   2.536 +    sta $578e
   2.537  
   2.538      lda #0          ; not on a character
   2.539 -    sta $3dfd
   2.540 +    sta $578d
   2.541  
   2.542      lda #0          ; reset the level number so that the correct tiles are used
   2.543 -    sta $3dfa
   2.544 +    sta $578a
   2.545  
   2.546      lda #3          ; cursor position in the high score entry held in $8d,$8e
   2.547      sta $8f
   2.548 @@ -5023,7 +5023,7 @@
   2.549  
   2.550          high_score_entry_aligned:
   2.551  
   2.552 -        lda $3dfd
   2.553 +        lda $578d
   2.554          cmp #1
   2.555          beq high_score_entry_next
   2.556  
   2.557 @@ -5091,12 +5091,12 @@
   2.558  
   2.559          high_score_entry_pressed:
   2.560          lda #1
   2.561 -        sta $3dfd
   2.562 +        sta $578d
   2.563          jmp high_score_entry_next
   2.564  
   2.565          high_score_entry_not_aligned:
   2.566          lda #0
   2.567 -        sta $3dfd
   2.568 +        sta $578d
   2.569  
   2.570          high_score_entry_next:
   2.571  
   2.572 @@ -5105,7 +5105,7 @@
   2.573  
   2.574          jmp high_score_entry_loop
   2.575  
   2.576 -        inc $3dfe
   2.577 +        inc $578e
   2.578          clc
   2.579  
   2.580      high_score_entry_after_loop:
   2.581 @@ -5163,15 +5163,15 @@
   2.582  
   2.583      ; Set the level.
   2.584      lda #0
   2.585 -    sta $3dfa
   2.586 +    sta $578a
   2.587  
   2.588      ; Set the score.
   2.589      lda #0
   2.590 -    sta $3df6
   2.591 +    sta $5786
   2.592      lda #0
   2.593 -    sta $3df7
   2.594 +    sta $5787
   2.595      lda #0
   2.596 -    sta $3df8
   2.597 +    sta $5788
   2.598  
   2.599      ; Blank the screen now because it will be blanked before the room is shown
   2.600      ; and otherwise the strength bar will show briefly.
   2.601 @@ -5179,14 +5179,14 @@
   2.602  
   2.603      ; Set the player's strength.
   2.604      lda #0
   2.605 -    sta $3df4
   2.606 +    sta $5784
   2.607      lda #64
   2.608      sta $70
   2.609      jsr add_strength
   2.610  
   2.611      ; Set the projectile type.
   2.612      lda #0
   2.613 -    sta $3df9
   2.614 +    sta $5789
   2.615  
   2.616      rts
   2.617  
   2.618 @@ -5211,26 +5211,26 @@
   2.619  
   2.620      ; Clear the item/player flags.
   2.621      lda #0
   2.622 -    sta $3df0
   2.623 +    sta $5780
   2.624  
   2.625      ; Set current room.
   2.626  
   2.627 -    ldx $3dfa
   2.628 +    ldx $578a
   2.629      lda start_rooms_y,x
   2.630 -    sta $3df2
   2.631 +    sta $5782
   2.632      lda start_rooms_x,x
   2.633 -    sta $3df3
   2.634 +    sta $5783
   2.635  
   2.636      ; Set the player's position.
   2.637  
   2.638      jsr reset_player_position
   2.639  
   2.640      ; Fill the treasure table with objects.
   2.641 -    ldx $3dfa   ; level
   2.642 +    ldx $578a   ; level
   2.643      lda key_rooms,x
   2.644      sta $80
   2.645      
   2.646 -    ldx $3dfa   ; level
   2.647 +    ldx $578a   ; level
   2.648      lda seeds,x
   2.649      adc #1
   2.650      and #31
   2.651 @@ -5242,9 +5242,9 @@
   2.652      sta $7d
   2.653      clc
   2.654  
   2.655 -    lda $3dfa   ; create an upper limit on the weapon type found in this level
   2.656 +    lda $578a   ; create an upper limit on the weapon type found in this level
   2.657      adc #2
   2.658 -    sta $3df1
   2.659 +    sta $5781
   2.660      clc
   2.661  
   2.662      lda #$00
   2.663 @@ -5288,7 +5288,7 @@
   2.664  
   2.665          ; Only add weapons with types that equal the level number or exceed it
   2.666          ; by one.
   2.667 -        cmp $3df1                     
   2.668 +        cmp $5781                     
   2.669          bcs start_level_add_treasure_none
   2.670  
   2.671          clc
   2.672 @@ -5341,9 +5341,9 @@
   2.673                  jsr reset_unplot_buffer
   2.674                  jsr reset_plot_buffer
   2.675  
   2.676 -                lda $3df2       ; current room (y)
   2.677 +                lda $5782       ; current room (y)
   2.678                  sta $78
   2.679 -                lda $3df3       ; current room (x)
   2.680 +                lda $5783       ; current room (x)
   2.681                  sta $79
   2.682                  jsr plot_room
   2.683                  jsr set_room_palette
   2.684 @@ -5353,13 +5353,13 @@
   2.685                  jsr plot_the_player
   2.686  
   2.687                  lda #0          ; reset projectile counter
   2.688 -                sta $3dfd
   2.689 +                sta $578d
   2.690  
   2.691                  lda #0          ; reset motion counter
   2.692 -                sta $3dfe
   2.693 +                sta $578e
   2.694  
   2.695                  lda #63         ; reset generation counter
   2.696 -                sta $3dff
   2.697 +                sta $578f
   2.698  
   2.699                  room_loop:
   2.700                      jsr reset_unplot_buffer
   2.701 @@ -5368,12 +5368,12 @@
   2.702                      jsr move_characters
   2.703                      jsr move_projectile
   2.704  
   2.705 -                    lda $3df0   ; is player out of strength?
   2.706 +                    lda $5780   ; is player out of strength?
   2.707                      and #$40
   2.708                      beq room_loop_player_move
   2.709                      clc
   2.710  
   2.711 -                    dec $3df5           ; leave the loop when the delay
   2.712 +                    dec $5785           ; leave the loop when the delay
   2.713                      beq after_room_loop ; counter is about to reset
   2.714  
   2.715                      lda $5181           ; leave the loop when the player
   2.716 @@ -5381,7 +5381,7 @@
   2.717                      beq room_loop_after_player_move
   2.718                      clc
   2.719  
   2.720 -                    lda $3dfe
   2.721 +                    lda $578e
   2.722                      and #7
   2.723                      bne room_loop_after_player_move
   2.724  
   2.725 @@ -5399,7 +5399,7 @@
   2.726                      room_loop_player_move:
   2.727  
   2.728                      ; See if it is time to generate a new enemy.
   2.729 -                    lda $3dff
   2.730 +                    lda $578f
   2.731                      cmp #0
   2.732                      bne no_emerge_characters
   2.733                      jsr emerge_characters
   2.734 @@ -5424,32 +5424,32 @@
   2.735                      beq game_over
   2.736                      clc
   2.737  
   2.738 -                    lda $3dfd
   2.739 +                    lda $578d
   2.740                      cmp #0
   2.741                      beq room_loop_no_update_projectile_counter
   2.742  
   2.743 -                    dec $3dfd
   2.744 +                    dec $578d
   2.745  
   2.746                      room_loop_no_update_projectile_counter:
   2.747  
   2.748 -                    dec $3dff   ; update generation counter
   2.749 -
   2.750 -                    inc $3dfe   ; update motion counter
   2.751 +                    dec $578f   ; update generation counter
   2.752 +
   2.753 +                    inc $578e   ; update motion counter
   2.754                      clc
   2.755                      jmp room_loop
   2.756  
   2.757                  after_room_loop:
   2.758                  clc
   2.759  
   2.760 -                lda $3df0
   2.761 +                lda $5780
   2.762                  and #$80
   2.763                  bne exit_level
   2.764  
   2.765 -                lda $3df0
   2.766 +                lda $5780
   2.767                  and #$40
   2.768                  bne game_over
   2.769  
   2.770 -                lda $3df0
   2.771 +                lda $5780
   2.772                  and #$02
   2.773                  bne complete_game
   2.774  
   2.775 @@ -5459,7 +5459,7 @@
   2.776  
   2.777              jsr show_end_of_level_screen
   2.778  
   2.779 -            inc $3dfa
   2.780 +            inc $578a
   2.781              jmp level_loop
   2.782  
   2.783              game_over: