Skip to content

Commit

Permalink
Moved some level-specific enemy move routines (large tank, spider, fl…
Browse files Browse the repository at this point in the history
…y, fireball) to script code. Fixed script entrypoint.
  • Loading branch information
cadaver committed Jan 22, 2016
1 parent 1c3ad24 commit 415d635
Show file tree
Hide file tree
Showing 11 changed files with 160 additions and 142 deletions.
8 changes: 4 additions & 4 deletions actordata.s
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@ alRat: dc.w MoveRat ;Update routine
dc.b -1 ;Height in chars for headbump check (negative)
dc.b -4*8 ;Jump initial speed (negative)

alSpider: dc.w MoveSpider ;Update routine
alSpider: dc.w USESCRIPT|EP_MOVESPIDER ;Update routine
dc.b GRP_ANIMALS|AF_NOWEAPON|AF_ORGANIC ;Actor flags
dc.b 10 ;Horizontal size
dc.b 10 ;Size up
Expand Down Expand Up @@ -1247,7 +1247,7 @@ alFly: dc.w MoveFly ;Update routine
dc.b 1 ;Horiz obstacle check offset
dc.b 1 ;Vert obstacle check offset

alBat: dc.w MoveBat ;Update routine
alBat: dc.w USESCRIPT|EP_MOVEBAT ;Update routine
dc.b GRP_ANIMALS|AF_NOWEAPON|AF_ORGANIC ;Actor flags
dc.b 7 ;Horizontal size
dc.b 8 ;Size up
Expand Down Expand Up @@ -1300,7 +1300,7 @@ alRock: dc.w MoveRock ;Update routine
dc.w 20 ;Score from kill
dc.b AIMODE_IDLE ;AI mode when spawned randomly

alFireball: dc.w MoveFireball ;Update routine
alFireball: dc.w USESCRIPT|EP_MOVEFIREBALL ;Update routine
dc.b GRP_ANIMALS ;Actor flags
dc.b 6 ;Horizontal size
dc.b 6 ;Size up
Expand Down Expand Up @@ -1551,7 +1551,7 @@ alJormungandr: dc.w USESCRIPT|EP_MOVEJORMUNGANDR ;Update routine
dc.b MOD_BOSS ;Damage modifier
dc.w 2500 ;Score from kill

alLargeTank: dc.w MoveLargeTank ;Update routine
alLargeTank: dc.w USESCRIPT|EP_MOVELARGETANK ;Update routine
dc.b GRP_ENEMIES|AF_NOWEAPON ;Actor flags
dc.b 24 ;Horizontal size
dc.b 41 ;Size up
Expand Down
Binary file modified bg/scorescr.chr
Binary file not shown.
Binary file modified bg/world.map
Binary file not shown.
Binary file modified bg/world10.map
Binary file not shown.
Binary file modified bg/world11.blk
Binary file not shown.
Binary file modified bg/world11.chr
Binary file not shown.
130 changes: 9 additions & 121 deletions enemy.s
Original file line number Diff line number Diff line change
Expand Up @@ -354,26 +354,6 @@ MR_DeadGrounded:lda #$00
sta actF1,x
MS_NoDamage: rts

; Spider movement
;
; Parameters: X actor index
; Returns: -
; Modifies: A,Y,temp1-temp8,loader temp vars

MoveSpider: lda #FR_DEADSPIDERGROUND
sta temp1
lda actHp,x
beq MR_Dead
jsr MoveGeneric
lda #2
ldy #2
jsr LoopingAnimation
MS_Damage: lda actFd,x
lsr
bcs MS_NoDamage ;Touch damage only each third frame
lda #DMG_SPIDER
jmp CollideAndDamagePlayer

; Fly movement
;
; Parameters: X actor index
Expand Down Expand Up @@ -402,40 +382,25 @@ MF_NoNewControls:
lda actFd,x
and #$01
sta actF1,x
jmp MS_Damage ;Use same damage code as spider
MS_Damage: lda actFd,x ;Common spider/fly damage code
lsr
bcs MS_NoDamage ;Touch damage only each third frame
lda #DMG_SPIDER
jmp CollideAndDamagePlayer
MF_Dead: lda #2
ldy #FR_DEADFLY+1
jmp OneShotAnimateAndRemove

; Bat movement
; Fish movement
;
; Parameters: X actor index
; Returns: -
; Modifies: A,Y,temp1-temp8,loader temp vars

MB_Dead: lda #FR_DEADBATGROUND
sta temp1
jmp MR_Dead
MoveBat: lda actHp,x
beq MB_Dead
lda #2 ;Wings flapping acceleration up
cmp actF1,x ;or gravity acceleration down,
bcc MB_Gravity ;depending on frame
lda actMoveCtrl,x
and #JOY_UP
bne MB_StrongFlap
lda #2
skip2
MB_StrongFlap: lda #7
bne MB_Accel
MB_Gravity: lda #2
MB_Accel: ldy #2*8
jsr AccActorYNegOrPos
lda #$00
sta temp6
jsr MFE_NoVertAccel ;Left/right acceleration & move
MoveFish: lda #CI_WATER
jsr MFE_CustomCharInfo
lda #2
ldy #FR_DEADBATGROUND-1
ldy #1
MB_BatCommon: jsr LoopingAnimation
ldy #ACTI_PLAYER
jsr GetActorDistance
Expand All @@ -445,18 +410,6 @@ MB_BatCommon: jsr LoopingAnimation
jmp MS_Damage
MB_NoDamage: rts

; Fish movement
;
; Parameters: X actor index
; Returns: -
; Modifies: A,Y,temp1-temp8,loader temp vars

MoveFish: lda #CI_WATER
jsr MFE_CustomCharInfo
lda #2
ldy #1
bne MB_BatCommon

; Rock movement
;
; Parameters: X actor index
Expand Down Expand Up @@ -529,41 +482,6 @@ MR_RandomizeSmallerRock:
sta actHp,x
rts

; Fireball movement
;
; Parameters: X actor index
; Returns: -
; Modifies: A,Y,temp1-temp8,loader temp vars

MoveFireball: lda actTime,x ;Randomize X-speed on first frame
bne MFB_HasRandomSpeed ;and set upward motion
inc actTime,x
jsr Random
and #$0f
sec
sbc #$08
sta actSX,x
jsr Random
and #$0f
sec
sbc #5*8+8
sta actSY,x
lda #SFX_GRENADELAUNCHER
jsr PlaySfx
MFB_HasRandomSpeed:
lda #DMG_FIREBALL
jsr CollideAndDamagePlayer
lda #1
ldy #3
jsr LoopingAnimation
lda #GRENADE_ACCEL-2
ldy #GRENADE_MAX_YSPEED
jsr AccActorY
lda actSX,x
jsr MoveActorX
lda actSY,x
jmp MoveActorY

; Steam movement
;
; Parameters: X actor index
Expand Down Expand Up @@ -642,36 +560,6 @@ MoveRockTrap: lda actYH,x ;Trigger when player is below
jmp InitActor
MRT_NoTrigger: rts

; Large tank update routine
;
; Parameters: X actor index
; Returns: -
; Modifies: A,Y,temp1-temp8,loader temp vars

MoveLargeTank: jsr MoveGeneric ;Use human movement for physics
jsr AttackGeneric
lda actSX,x ;Then overwrite animation
beq MLT_NoCenterFrame
eor actD,x ;If direction & speed don't agree, show the
bmi MLT_CenterFrame ;center frame (turning)
MLT_NoCenterFrame:
jsr GetAbsXSpeed
clc
adc actFd,x
cmp #$60
bcc MLT_NoWrap
sbc #$60
MLT_NoWrap: sta actFd,x
lsr
lsr
lsr
lsr
lsr
skip2
MLT_CenterFrame:lda #3
sta actF1,x
rts

; High walker movement
;
; Parameters: X actor index
Expand Down
8 changes: 7 additions & 1 deletion script.s
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ EP_MOVELARGESPIDER = $020e
EP_OPENWALL = $020f
EP_MOVEACID = $0210
EP_RADIOCAVES = $0211
EP_MOVEBAT = $0212
EP_MOVESPIDER = $0213

EP_RADIOLOWERLABS = $0300
EP_HACKERAMBUSH = $0301
Expand Down Expand Up @@ -90,6 +92,8 @@ EP_TUNNELMACHINERUN = $0514
EP_RADIOJORMUNGANDR = $0515
EP_RADIOJORMUNGANDRRUN = $0516
EP_DESTROYPLAN = $0517
EP_MOVELARGETANK = $0518
EP_MOVEFIREBALL = $0519

EP_MOVEJORMUNGANDR = $0600

Expand Down Expand Up @@ -153,7 +157,9 @@ TEXT_RADIOABANDONED = $0501
TEXT_RADIOTRIGGEREND = $0502
TEXT_SECURITYCHIEF = $0503
TEXT_RADIOINSTALLLAPTOP = $0504
TEXT_RADIOINSTALLLAPTOPFINISH = $0505
TEXT_RADIOSIGNALUNKNOWN = $0505
TEXT_RADIOSIGNALKNOWN = $0506
TEXT_RADIOINSTALLLAPTOPFINISH = $0507

TEXT_ENTEROLDTUNNELS = $0600
TEXT_ENTERLAB = $0601
Expand Down
54 changes: 54 additions & 0 deletions script02.s
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ CHUNK_DURATION = 40
dc.w OpenWall
dc.w MoveAcid
dc.w RadioCaves
dc.w MoveBat
dc.w MoveSpider

; Finalize game start. Create persistent NPCs to the leveldata and randomize entry codes
;
Expand Down Expand Up @@ -954,6 +956,58 @@ MA_StartPlayerSplash:
RadioCaves: gettext TEXT_ENTERCAVES
jmp RadioMsg

; Bat movement
;
; Parameters: X actor index
; Returns: -
; Modifies: A,Y,temp1-temp8,loader temp vars

MB_Dead: lda #FR_DEADBATGROUND
sta temp1
jmp MR_Dead
MoveBat: ldy #C_ANIMALS
jsr EnsureSpriteFile
lda actHp,x
beq MB_Dead
lda #2 ;Wings flapping acceleration up
cmp actF1,x ;or gravity acceleration down,
bcc MB_Gravity ;depending on frame
lda actMoveCtrl,x
and #JOY_UP
bne MB_StrongFlap
lda #2
skip2
MB_StrongFlap: lda #7
bne MB_Accel
MB_Gravity: lda #2
MB_Accel: ldy #2*8
jsr AccActorYNegOrPos
lda #$00
sta temp6
jsr MFE_NoVertAccel ;Left/right acceleration & move
lda #2
ldy #FR_DEADBATGROUND-1
jmp MB_BatCommon

; Spider movement
;
; Parameters: X actor index
; Returns: -
; Modifies: A,Y,temp1-temp8,loader temp vars

MoveSpider: ldy #C_ANIMALS
jsr EnsureSpriteFile
lda #FR_DEADSPIDERGROUND
sta temp1
lda actHp,x
bne MS_Alive
jmp MR_Dead
MS_Alive: jsr MoveGeneric
lda #2
ldy #2
jsr LoopingAnimation
jmp MS_Damage

; Variables

laserTime: dc.b 0
Expand Down
Loading

0 comments on commit 415d635

Please sign in to comment.