junglejourney

changeset 177:7e9e62f1d98c

Made certain types of enemies have non-homing behaviour.
author David Boddie <david@boddie.org.uk>
date Sat Sep 24 00:59:08 2011 +0200
parents 7fcebabb9fec
children 893f1688200b
files build.py mapcode.oph
diffstat 2 files changed, 74 insertions(+), 9 deletions(-) [+]
line diff
     1.1 --- a/build.py	Fri Sep 23 20:10:08 2011 +0200
     1.2 +++ b/build.py	Sat Sep 24 00:59:08 2011 +0200
     1.3 @@ -83,6 +83,7 @@
     1.4      #        projectile: bits 4,5 are direction, bits 1,2 are type,
     1.5      #                    bit 0 is animation
     1.6      #        enemy:  bits 2,3 are direction, bits 1,0 are animation
     1.7 +    #                bits 4,5,6,7 are counter for non-homing enemies
     1.8      #        emerging, explosion: bits 4,5,6 are enemy type for emerging,
     1.9      #                             bit 2 is type 0=emerge,1=explode,
    1.10      #                             bits 0,1 are animation
    1.11 @@ -168,6 +169,9 @@
    1.12      code_start = 0x1e00
    1.13      files.append(("CODE", code_start, code_start, code))
    1.14      
    1.15 +    copying = open("COPYING").read()
    1.16 +    files.append(("COPYING", 0xe00, 0xe00, copying))
    1.17 +    
    1.18      u = UEFfile.UEFfile(creator = 'build.py '+version)
    1.19      u.minor = 6
    1.20      u.target_machine = "Electron"
     2.1 --- a/mapcode.oph	Fri Sep 23 20:10:08 2011 +0200
     2.2 +++ b/mapcode.oph	Sat Sep 24 00:59:08 2011 +0200
     2.3 @@ -2403,7 +2403,7 @@
     2.4  
     2.5      ldy #1
     2.6      lda ($74),y
     2.7 -    and #$0b    ; keep vertical direction bit and animation bits
     2.8 +    and #$fb    ; keep vertical direction bit and animation bits
     2.9      sta ($74),y ; left (horizontal directional bit is 0)
    2.10  
    2.11      rts
    2.12 @@ -2573,7 +2573,7 @@
    2.13  
    2.14      ldy #1
    2.15      lda ($74),y
    2.16 -    and #$07    ; keep horizontal direction bit and animation bits
    2.17 +    and #$f7    ; keep horizontal direction bit and animation bits
    2.18      sta ($74),y
    2.19  
    2.20      rts
    2.21 @@ -2739,15 +2739,18 @@
    2.22      ldy #1
    2.23      lda ($74),y         ; direction/animation
    2.24      sta $81
    2.25 +    and #$03
    2.26      adc #1
    2.27      and #$03            ; keep animation bits
    2.28      sta $8f
    2.29      lda $81
    2.30 -    and #$0c            ; mask off the animation bits
    2.31 +    and #$fc            ; mask off the animation bits
    2.32      ora $8f
    2.33      sta ($74),y
    2.34      rts
    2.35  
    2.36 +move_enemy_next_direction: .byte $04, $0c, $00, $08
    2.37 +
    2.38  move_enemy:             ; $74,$75=character address
    2.39  
    2.40      lda #0
    2.41 @@ -2755,6 +2758,61 @@
    2.42      lda #0
    2.43      sta $8e             ; horizontal motion value (0=no motion; 1=left; 2=right)
    2.44  
    2.45 +    lda ($74),y         ; read the enemy number (Y should be zero)
    2.46 +    and #$50
    2.47 +    beq move_enemy_homing
    2.48 +    clc
    2.49 +
    2.50 +    ; This enemy is a non-homing enemy.
    2.51 +
    2.52 +    jsr unplot_character    ; unplot now before we change the sprite used
    2.53 +
    2.54 +    ldy #1
    2.55 +    lda ($74),y
    2.56 +    and #$f0
    2.57 +    cmp #$f0
    2.58 +    bne move_enemy_set_direction
    2.59 +    clc
    2.60 +
    2.61 +    ldy #1
    2.62 +    lda ($74),y
    2.63 +    and #$0c
    2.64 +    ror
    2.65 +    ror
    2.66 +    tax
    2.67 +    lda move_enemy_next_direction,x
    2.68 +    sta ($74),y
    2.69 +
    2.70 +    move_enemy_set_direction:
    2.71 +    clc
    2.72 +
    2.73 +    ldy #1
    2.74 +    lda ($74),y
    2.75 +    sta $7b
    2.76 +
    2.77 +    adc #$10
    2.78 +    sta ($74),y
    2.79 +    clc
    2.80 +
    2.81 +    lda $7b
    2.82 +    and #$04
    2.83 +    ror
    2.84 +    ror
    2.85 +    adc #1
    2.86 +    sta $8e
    2.87 +
    2.88 +    lda $7b
    2.89 +    and #$08
    2.90 +    ror
    2.91 +    ror
    2.92 +    ror
    2.93 +    adc #1
    2.94 +    sta $8d
    2.95 +
    2.96 +    jmp move_enemy_with_direction
    2.97 +
    2.98 +    move_enemy_homing:
    2.99 +
   2.100      ldy #2
   2.101      lda ($74),y         ; y
   2.102      cmp $5282           ; player y
   2.103 @@ -2787,23 +2845,26 @@
   2.104      ldy #5
   2.105      lda ($74),y         ; dx
   2.106      cmp #0
   2.107 -    beq move_enemy_with_direction
   2.108 +    beq move_enemy_with_direction_unplot
   2.109      bpl move_enemy_leftwards
   2.110  
   2.111      move_enemy_rightwards:
   2.112      lda #2
   2.113      sta $8e
   2.114 -    jmp move_enemy_with_direction
   2.115 +    jmp move_enemy_with_direction_unplot
   2.116  
   2.117      move_enemy_leftwards:
   2.118      lda #1
   2.119      sta $8e
   2.120  
   2.121 +    move_enemy_with_direction_unplot:
   2.122 +    clc
   2.123 +
   2.124 +    jsr unplot_character
   2.125 +
   2.126      move_enemy_with_direction:
   2.127      clc
   2.128  
   2.129 -    jsr unplot_character
   2.130 -
   2.131      lda $8e
   2.132      cmp #1
   2.133      bne move_enemy_not_left
   2.134 @@ -3536,8 +3597,8 @@
   2.135  
   2.136          lda $74                     ; for the last enemy, check the next slot
   2.137          cmp #$9e                    ; for the presence of an explosion
   2.138 -        bne move_characters_endloop
   2.139 -        clc
   2.140 +        bne move_characters_endloop ; otherwise leave the loop (only performing
   2.141 +        clc                         ; one iteration)
   2.142  
   2.143          adc #6
   2.144          sta $74