dos33fsprogs/ootw/sluggy.s

437 lines
6.6 KiB
ArmAsm
Raw Normal View History

2019-01-20 04:51:58 +00:00
; Sluggy Freelance
2019-01-24 21:03:29 +00:00
; slug behavior:
; cavern1: three slugs: 2 on ceiling
; cavern2: four slugs: 1 on ceiling, but 3 more will respawn on ceiling
; Crawl forward. When close, attack.
; Ceiling: crawl until within X of physicist
; then swing a few times and fall
; face toward physicist when start crawling
; Attacks: only attack if on ground and physicist is on ground
; will attempt to attack if you jump over
; Off edge of screen: will disappear but will respawn if leave/re-enter
2019-01-20 04:51:58 +00:00
;==================================
; draw slugs
;==================================
2019-01-24 21:03:29 +00:00
SLUG_STRUCT_SIZE = 8
2019-01-23 20:36:20 +00:00
2019-01-24 21:03:29 +00:00
; TODO: use less space? merge some of these?
2019-01-20 04:51:58 +00:00
slugg0_out: .byte 1 ; 0
slugg0_attack: .byte 0 ; 1
2019-01-21 05:07:32 +00:00
slugg0_dying: .byte 0 ; 2
2019-01-20 04:51:58 +00:00
slugg0_x: .byte 30 ; 3
2019-01-24 21:03:29 +00:00
slugg0_y: .byte 30 ; 4
slugg0_dir: .byte $ff ; 5
slugg0_gait: .byte 0 ; 6
slugg0_falling: .byte 0 ; 7
2019-01-20 04:51:58 +00:00
2019-01-24 21:03:29 +00:00
slugg1_out: .byte 1 ; 8
2019-01-20 04:51:58 +00:00
slugg1_attack: .byte 0
2019-01-21 05:07:32 +00:00
slugg1_dying: .byte 0
2019-01-20 04:51:58 +00:00
slugg1_x: .byte 30
2019-01-23 20:36:20 +00:00
slugg1_y: .byte 30
2019-01-20 04:51:58 +00:00
slugg1_dir: .byte $ff
slugg1_gait: .byte 0
2019-01-24 21:03:29 +00:00
slugg1_falling: .byte 0
2019-01-20 04:51:58 +00:00
slugg2_out: .byte 1
slugg2_attack: .byte 0
2019-01-21 05:07:32 +00:00
slugg2_dying: .byte 0
2019-01-20 04:51:58 +00:00
slugg2_x: .byte 30
slugg2_y: .byte 2
2019-01-20 04:51:58 +00:00
slugg2_dir: .byte $ff
slugg2_gait: .byte 0
2019-01-24 21:03:29 +00:00
slugg2_falling: .byte 0
2019-01-20 04:51:58 +00:00
2019-01-21 04:46:05 +00:00
slugg3_out: .byte 1 ; 0
slugg3_attack: .byte 0 ; 1
2019-01-21 05:07:32 +00:00
slugg3_dying: .byte 0 ; 2
2019-01-21 04:46:05 +00:00
slugg3_x: .byte 30 ; 3
2019-01-24 21:03:29 +00:00
slugg3_y: .byte 30 ; 4
slugg3_dir: .byte $ff ; 5
slugg3_gait: .byte 0 ; 6
slugg3_falling: .byte 0 ; 7
2019-01-20 04:51:58 +00:00
2019-01-21 04:46:05 +00:00
slugg4_out: .byte 1 ; 6
slugg4_attack: .byte 0
2019-01-21 05:07:32 +00:00
slugg4_dying: .byte 0
2019-01-21 04:46:05 +00:00
slugg4_x: .byte 30
2019-01-23 20:36:20 +00:00
slugg4_y: .byte 30
2019-01-21 04:46:05 +00:00
slugg4_dir: .byte $ff
slugg4_gait: .byte 0
2019-01-24 21:03:29 +00:00
slugg4_falling: .byte 0
2019-01-21 04:46:05 +00:00
slugg5_out: .byte 1
slugg5_attack: .byte 0
2019-01-21 05:07:32 +00:00
slugg5_dying: .byte 0
2019-01-21 04:46:05 +00:00
slugg5_x: .byte 30
2019-01-23 20:36:20 +00:00
slugg5_y: .byte 30
2019-01-21 04:46:05 +00:00
slugg5_dir: .byte $ff
slugg5_gait: .byte 0
2019-01-24 21:03:29 +00:00
slugg5_falling: .byte 0
2019-01-21 04:46:05 +00:00
2019-01-21 05:07:32 +00:00
slugg6_out: .byte 1
slugg6_attack: .byte 0
slugg6_dying: .byte 0
slugg6_x: .byte 30
slugg6_y: .byte 2
2019-01-21 05:07:32 +00:00
slugg6_dir: .byte $ff
slugg6_gait: .byte 0
2019-01-24 21:03:29 +00:00
slugg6_falling: .byte 0
2019-01-21 05:07:32 +00:00
2019-01-23 20:36:20 +00:00
slugg7_out: .byte 1
slugg7_attack: .byte 0
slugg7_dying: .byte 0
slugg7_x: .byte 30
slugg7_y: .byte 2
2019-01-23 20:36:20 +00:00
slugg7_dir: .byte $ff
slugg7_gait: .byte 0
2019-01-24 21:03:29 +00:00
slugg7_falling: .byte 0
2019-01-21 04:46:05 +00:00
;========================
; Init the slug creatures
;========================
init_slugs:
ldx #0
init_slug_loop:
2019-01-21 05:07:32 +00:00
; Mark slug as out and alive
2019-01-21 04:46:05 +00:00
lda #1
sta slugg0_out,X
2019-01-21 05:07:32 +00:00
; Mark slug as not attacking or dying
2019-01-21 04:46:05 +00:00
lda #0
sta slugg0_attack,X
2019-01-21 05:07:32 +00:00
sta slugg0_dying,X
; Point the slug in the correct direction (left in this case)
2019-01-21 04:46:05 +00:00
lda #$ff
sta slugg0_dir,X
2019-01-21 05:07:32 +00:00
; Randomly pick an X value to appear at
2019-01-21 04:46:05 +00:00
jsr random16
2019-01-21 05:07:32 +00:00
lda SEEDL
and #$1f
2019-01-21 04:46:05 +00:00
clc
adc #8 ; appear from x = 8..32
2019-01-21 05:07:32 +00:00
cmp #32
2019-01-21 05:07:32 +00:00
bcc slugx_not_too_high ; blt
lsr ; div by two if too large
2019-01-21 05:07:32 +00:00
slugx_not_too_high:
2019-01-21 04:46:05 +00:00
sta slugg0_x,X
2019-01-21 05:07:32 +00:00
; Make the slug movement random so they don't all move in sync
2019-01-21 04:46:05 +00:00
jsr random16
2019-01-21 05:07:32 +00:00
lda SEEDL
2019-01-21 04:46:05 +00:00
sta slugg0_gait,X
2019-01-21 05:07:32 +00:00
; incrememnt struct pointer until all are initialized
2019-01-21 04:46:05 +00:00
clc
txa
2019-01-23 20:36:20 +00:00
adc #SLUG_STRUCT_SIZE
2019-01-21 04:46:05 +00:00
tax
2019-01-23 20:36:20 +00:00
cpx #(SLUG_STRUCT_SIZE*8)
2019-01-21 04:46:05 +00:00
bne init_slug_loop
2019-01-21 05:07:32 +00:00
; FIXME: originally forced some spacing between them
2019-01-21 04:46:05 +00:00
rts
;========================
; Draw the slug creatures
;========================
2019-01-20 04:51:58 +00:00
draw_slugs:
2019-01-21 05:07:32 +00:00
ds_smc1:
2019-01-24 21:03:29 +00:00
ldx #0 ; loop through all. self-modify
2019-01-20 04:51:58 +00:00
stx WHICH_SLUG
draw_slugs_loop:
ldx WHICH_SLUG
lda slugg0_out,X
bne check_kicked ; don't draw if not there
jmp slug_done
check_kicked:
lda slugg0_out,X ; only kick if normal
cmp #1
bne check_attack
2019-01-24 21:03:29 +00:00
lda slugg0_y,X ; only kick if on ground
cmp #30
bne check_attack
2019-01-20 04:51:58 +00:00
;==================
; see if kicked
lda PHYSICIST_STATE
cmp #P_KICKING
2019-01-20 04:51:58 +00:00
beq check_attack
lda PHYSICIST_X
sec
sbc slugg0_x,X ; -4 to +4
clc
adc #4
and #$f8
bne not_kicked
kicked:
lda #2
sta slugg0_out,X
lda #10
2019-01-21 05:07:32 +00:00
sta slugg0_dying,X
2019-01-20 04:51:58 +00:00
lda DIRECTION
sta slugg0_dir,X
not_kicked:
check_attack:
;==================
; see if attack
2019-01-24 21:03:29 +00:00
lda slugg0_out,X ; only attack if out
2019-01-20 04:51:58 +00:00
cmp #1
bne no_attack
2019-01-24 21:03:29 +00:00
lda slugg0_y,X ; only attack if on ground
cmp #30
bne no_attack
lda PHYSICIST_Y ; only attack if physicist on ground
cmp #22
bne no_attack
2019-01-20 04:51:58 +00:00
lda PHYSICIST_X
sec
sbc slugg0_x,X ; -2 to +2
clc
adc #2
and #$fc
bne no_attack
attack:
;=================
; start an attack
lda #1
sta slugg0_attack,X
lda SLUGDEATH ; don't re-attack if already dead
bne no_attack
lda #$1
sta SLUGDEATH
lda #0
sta SLUGDEATH_PROGRESS
stx WHICH_SLUG
jsr slug_cutscene
ldx WHICH_SLUG
no_attack:
inc slugg0_gait,X ; increment slug gait counter
lda slugg0_gait,X ; only move every 64 frames
and #$3f
cmp #$00
bne slug_no_move
slug_move:
lda slugg0_x,X
clc
adc slugg0_dir,X
sta slugg0_x,X
slug_check_right:
cmp #37
bne slug_check_left
jmp remove_slug
slug_check_left:
cmp #0
bne slug_no_move
jmp remove_slug
slug_no_move:
;===============================
;===============================
; DRAW SLUG
;===============================
;===============================
;==============
; if exploding
;==============
2019-01-21 05:07:32 +00:00
lda slugg0_dying,X
2019-01-20 04:51:58 +00:00
beq check_draw_attacking
slug_exploding:
stx WHICH_SLUG
tax ; urgh can't forget tax
lda slug_die_progression,X
sta INL
lda slug_die_progression+1,X
sta INH
ldx WHICH_SLUG
bit SPEAKER
lda FRAMEL
and #$f
bne no_progress
bit SPEAKER
2019-01-21 05:07:32 +00:00
dec slugg0_dying,X
dec slugg0_dying,X
2019-01-20 04:51:58 +00:00
bne no_progress
jmp remove_slug
no_progress:
jmp slug_selected
;==============
; if attacking
;==============
check_draw_attacking:
lda slugg0_attack,X
beq check_slug_ceiling
2019-01-20 04:51:58 +00:00
slug_attacking:
lda slugg0_gait,X
stx WHICH_SLUG
and #$70
lsr
lsr
lsr
tax
lda slug_attack_progression,X
sta INL
lda slug_attack_progression+1,X
sta INH
ldx WHICH_SLUG
jmp slug_selected
;==============
; if on ceiling
;==============
check_slug_ceiling:
lda slugg0_y,X
cmp #30
beq slug_normal
slug_ceiling:
lda slugg0_gait,X
and #$20
beq slug_ceiling_squinched
slug_ceiling_flat:
lda #<slug_ceiling1
sta INL
lda #>slug_ceiling1
sta INH
bne slug_selected
slug_ceiling_squinched:
lda #<slug_ceiling2
sta INL
lda #>slug_ceiling2
sta INH
jmp slug_selected
2019-01-20 04:51:58 +00:00
;==============
; if normal
;==============
slug_normal:
lda slugg0_gait,X
and #$20
beq slug_squinched
slug_flat:
lda #<slug1
sta INL
lda #>slug1
sta INH
bne slug_selected
slug_squinched:
lda #<slug2
sta INL
lda #>slug2
sta INH
;================
; end slug normal
;================
slug_selected:
lda slugg0_x,X
sta XPOS
2019-01-23 20:36:20 +00:00
lda slugg0_y,X
2019-01-20 04:51:58 +00:00
sec
sbc EARTH_OFFSET
sta YPOS
lda slugg0_dir,X
stx WHICH_SLUG
bmi slug_right
slug_left:
jsr put_sprite
jmp slug_done
slug_right:
jsr put_sprite_flipped
slug_done:
lda WHICH_SLUG
clc
2019-01-23 20:36:20 +00:00
adc #SLUG_STRUCT_SIZE
2019-01-20 04:51:58 +00:00
tax
stx WHICH_SLUG
2019-01-21 05:07:32 +00:00
ds_smc2:
2019-01-23 20:36:20 +00:00
cpx #(3*SLUG_STRUCT_SIZE)
2019-01-20 04:51:58 +00:00
beq slug_exit
jmp draw_slugs_loop
slug_exit:
rts
remove_slug:
lda #0
sta slugg0_out,X
jmp slug_done