junglejourney

changeset 43:4d9da53995ae

Added a global counter to limit the motion of characters.
author David Boddie <david@boddie.org.uk>
date Sun Aug 21 19:22:14 2011 +0200
parents 99ef92fc83ae
children 5a120c2b6e89
files build.py mapcode.oph
diffstat 2 files changed, 47 insertions(+), 36 deletions(-) [+]
line diff
     1.1 --- a/build.py	Sun Aug 21 18:57:07 2011 +0200
     1.2 +++ b/build.py	Sun Aug 21 19:22:14 2011 +0200
     1.3 @@ -52,13 +52,12 @@
     1.4      # 3300 character table (0x24/6 = 6 entries)
     1.5      #   n   type (0 missing, 1 player, 2 projectile, 3 explosion,
     1.6      #             4 and higher enemy - bits 3,4,5 are enemy type)
     1.7 -    #   n+1 counter/direction (player: bits 1,2 are direction,
     1.8 -    #                                  bit 0 is animation
     1.9 -    #                  enemy:  bits 4,5 are direction,
    1.10 -    #                          bits 2,3 are animation, bits 0,1 are delay bits)
    1.11 -    #  (emerging, explosion: bits 4,5,6 are enemy type for emerging,
    1.12 -    #                               bit 3 is type 0=emerge,1=explode,
    1.13 -    #                        bits 0,1,2 are animation with bit 0 a delay bit)
    1.14 +    #   n+1 counter/direction
    1.15 +    #       (player: bits 1,2 are direction, bit 0 is animation
    1.16 +    #        enemy:  bits 2,3 are direction, bits 1,0 are animation
    1.17 +    #        emerging, explosion: bits 4,5,6 are enemy type for emerging,
    1.18 +    #                             bit 3 is type 0=emerge,1=explode,
    1.19 +    #                             bits 0,1 are animation)
    1.20      #   n+2 y room offset (0-10)
    1.21      #   n+3 dy (0-5)
    1.22      #   n+4 x room offset (0-10)
    1.23 @@ -81,7 +80,8 @@
    1.24      # 33F6 score (four bytes)
    1.25      # 33FA level
    1.26      # 33FB palette workspace (enough for one 5 byte palette entry)
    1.27 -    #       33FE and 33FF are also enemy generation counter when in a room
    1.28 +    #       33FE is also motion counter when in a room
    1.29 +    #       33FF is also enemy generation counter when in a room
    1.30      #
    1.31      # 3400 CHARS (character sprites)
    1.32      #       4 * 2 * 0x30 (player movement)
     2.1 --- a/mapcode.oph	Sun Aug 21 18:57:07 2011 +0200
     2.2 +++ b/mapcode.oph	Sun Aug 21 19:22:14 2011 +0200
     2.3 @@ -1181,9 +1181,8 @@
     2.4  
     2.5      ; Select the sprites to use.
     2.6  
     2.7 -    lda $80         ; remove the least significant bit, used to delay
     2.8 -    lsr             ; the animation
     2.9 -    and #7          ; only keep the bits required to find the correct sprite
    2.10 +    lda $80
    2.11 +    and #3          ; only keep the bits required to find the correct sprite
    2.12      clc
    2.13      tax
    2.14      lda emerge_explode_chars_low,x
    2.15 @@ -1208,10 +1207,7 @@
    2.16      sta $71 ; 0x00, 0x02, 0x04, 0x06, 0x08
    2.17  
    2.18      lda $80
    2.19 -    lsr             ; remove the least significant bits, used to delay
    2.20 -    lsr             ; the animation
    2.21 -    and #7          ; remove the top direction bit
    2.22 -    clc
    2.23 +    and #7          ; keep the animation bits
    2.24      tax
    2.25      lda enemy_direction_chars_low,x
    2.26      sta $70
    2.27 @@ -1415,6 +1411,15 @@
    2.28  
    2.29  move_player:
    2.30  
    2.31 +    lda $33fe
    2.32 +    and #1
    2.33 +    beq move_player_allowed
    2.34 +
    2.35 +    clc
    2.36 +    rts
    2.37 +
    2.38 +    move_player_allowed:
    2.39 +
    2.40      lda #$00    ; set up the address of the player character
    2.41      sta $74
    2.42      lda #$33
    2.43 @@ -1850,7 +1855,7 @@
    2.44      lda ($74),y     ; direction/animation
    2.45      tax
    2.46      adc #1          ; update the counter
    2.47 -    and #7          ; mask off everything else
    2.48 +    and #3          ; mask off everything else
    2.49      sta $80         ; store the masked counter value
    2.50      bne move_characters_explosion_not_finished
    2.51  
    2.52 @@ -1901,7 +1906,7 @@
    2.53  
    2.54      ldy #1
    2.55      lda ($74),y
    2.56 -    and #$2f    ; keep vertical direction bit and animation bits
    2.57 +    and #$0b    ; keep vertical direction bit and animation bits
    2.58      sta ($74),y ; left (horizontal directional bit is 0)
    2.59  
    2.60      rts
    2.61 @@ -1980,7 +1985,7 @@
    2.62  
    2.63      ldy #1
    2.64      lda ($74),y
    2.65 -    ora #$10    ; right (keep vertical direction bit and animation bits)
    2.66 +    ora #$04    ; right (keep vertical direction bit and animation bits)
    2.67      sta ($74),y
    2.68  
    2.69      rts
    2.70 @@ -2039,6 +2044,7 @@
    2.71      bne move_enemy_right_exit
    2.72  
    2.73      move_enemy_allow_right:
    2.74 +    clc
    2.75  
    2.76      ldy #5
    2.77      lda ($74),y                 ; dx
    2.78 @@ -2070,7 +2076,7 @@
    2.79  
    2.80      ldy #1
    2.81      lda ($74),y
    2.82 -    and #$1f    ; keep horizontal direction bit and animation bits
    2.83 +    and #$07    ; keep horizontal direction bit and animation bits
    2.84      sta ($74),y
    2.85  
    2.86      rts
    2.87 @@ -2146,8 +2152,7 @@
    2.88  
    2.89      ldy #1
    2.90      lda ($74),y
    2.91 -    and #$1f    ; keep horizontal direction bit and animation bits
    2.92 -    ora #$20    ; down
    2.93 +    ora #$08    ; down
    2.94      sta ($74),y
    2.95  
    2.96      rts
    2.97 @@ -2206,6 +2211,7 @@
    2.98      bne move_enemy_down_exit
    2.99  
   2.100      move_enemy_allow_down:
   2.101 +    clc
   2.102  
   2.103      ldy #3
   2.104      lda ($74),y                 ; dy
   2.105 @@ -2237,26 +2243,16 @@
   2.106      lda ($74),y         ; direction/animation
   2.107      sta $81
   2.108      adc #1
   2.109 -    and #$0f            ; keep animation bits
   2.110 +    and #$03            ; keep animation bits
   2.111      sta $8f
   2.112      lda $81
   2.113 -    and #$30            ; mask off the animation bits
   2.114 +    and #$0c            ; mask off the animation bits
   2.115      ora $8f
   2.116      sta ($74),y
   2.117      rts
   2.118  
   2.119  move_enemy:             ; $74,$75=character address
   2.120  
   2.121 -    ldy #1
   2.122 -    lda ($74),y                 ; direction/animation
   2.123 -    and #3
   2.124 -    cmp #3
   2.125 -    beq move_enemy_now
   2.126 -    
   2.127 -    clc
   2.128 -    jmp move_enemy_animate      ; optimise away the rts
   2.129 -
   2.130 -    move_enemy_now:
   2.131      lda #0
   2.132      sta $8d
   2.133      lda #0
   2.134 @@ -2352,8 +2348,6 @@
   2.135  
   2.136  move_characters:
   2.137  
   2.138 -    dec $33ff
   2.139 -
   2.140      lda #$0c            ; set the character address
   2.141      sta $74
   2.142      lda #$33
   2.143 @@ -2380,6 +2374,10 @@
   2.144          cmp #3
   2.145          bne move_characters_not_emerge_explode
   2.146  
   2.147 +        lda $33fe           ; check motion counter
   2.148 +        and #1
   2.149 +        bne move_characters_next
   2.150 +
   2.151          jsr emerge_explode
   2.152          jmp move_characters_next
   2.153  
   2.154 @@ -2387,6 +2385,10 @@
   2.155          cmp #4
   2.156          bmi move_characters_next
   2.157  
   2.158 +        lda $33fe           ; check motion counter
   2.159 +        and #3
   2.160 +        bne move_characters_next
   2.161 +
   2.162          jsr move_enemy
   2.163  
   2.164          move_characters_next:
   2.165 @@ -2566,6 +2568,7 @@
   2.166              lda $33f3
   2.167              sta $79
   2.168              jsr plot_room
   2.169 +
   2.170              jsr remove_characters
   2.171  
   2.172              jsr reset_unplot_buffer
   2.173 @@ -2579,7 +2582,10 @@
   2.174  
   2.175              jsr plot_buffer
   2.176  
   2.177 -            lda #63
   2.178 +            lda #0         ; reset motion counter
   2.179 +            sta $33fe
   2.180 +
   2.181 +            lda #63         ; reset generation counter
   2.182              sta $33ff
   2.183  
   2.184              room_loop:
   2.185 @@ -2598,6 +2604,11 @@
   2.186                  cpy #255
   2.187                  beq exit
   2.188                  clc
   2.189 +
   2.190 +                dec $33ff   ; update generation counter
   2.191 +
   2.192 +                inc $33fe   ; update motion counter
   2.193 +                clc
   2.194                  jmp room_loop
   2.195  
   2.196          after_room_loop: