dos33fsprogs/ootw/alien.s

429 lines
5.7 KiB
ArmAsm
Raw Normal View History

2019-07-18 17:53:52 +00:00
; draw/move the bad guy aliens
MAX_ALIENS = 3
2019-07-18 17:53:52 +00:00
alien_out:
alien0_out: .byte 0
2019-07-18 17:53:52 +00:00
alien1_out: .byte 0
alien2_out: .byte 0
alien_room:
alien0_room: .byte 0
alien1_room: .byte 0
alien2_room: .byte 0
alien_x:
alien0_x: .byte 0
2019-07-18 17:53:52 +00:00
alien1_x: .byte 0
alien2_x: .byte 0
alien_y:
alien0_y: .byte 0
2019-07-18 17:53:52 +00:00
alien1_y: .byte 0
alien2_y: .byte 0
alien_state:
alien0_state: .byte 0
2019-07-18 17:53:52 +00:00
alien1_state: .byte 0
alien2_state: .byte 0
A_STANDING = 0
A_WALKING = 1
A_RUNNING = 2
A_CROUCHING = 3
A_TURNING = 4
A_YELLING = 5
A_SHOOTING_UP = 6
A_DISINTEGRATING = 7
alien_gait:
alien0_gait: .byte 0
2019-07-18 17:53:52 +00:00
alien1_gait: .byte 0
alien2_gait: .byte 0
alien_direction:
alien0_direction: .byte 0
2019-07-18 17:53:52 +00:00
alien1_direction: .byte 0
alien2_direction: .byte 0
alien_gun:
alien0_gun: .byte 0
2019-07-18 20:18:19 +00:00
alien1_gun: .byte 0
alien2_gun: .byte 0
2019-07-18 17:53:52 +00:00
;=======================================
; Move alien based on current state
;
move_alien:
; FIXME: loop through all alieans
ldx #0
lda alien_out,X
2019-07-18 17:53:52 +00:00
beq done_move_alien
lda alien_state,X
2019-07-18 17:53:52 +00:00
cmp #A_WALKING
2019-07-18 17:53:52 +00:00
beq move_alien_walking
cmp #A_RUNNING
2019-07-18 17:53:52 +00:00
beq move_alien_running
cmp #A_YELLING
beq move_alien_yelling
2019-07-19 00:10:09 +00:00
cmp #A_SHOOTING_UP
beq move_alien_yelling
2019-07-18 17:53:52 +00:00
done_move_alien:
rts
;======================
; yelling
move_alien_yelling:
inc alien_gait,X ; cycle through animation
rts
2019-07-18 17:53:52 +00:00
;======================
; walking
move_alien_walking:
inc alien_gait,X ; cycle through animation
2019-07-18 17:53:52 +00:00
lda alien_gait,X
2019-07-18 19:29:30 +00:00
and #$f
cmp #$8 ; only walk roughly 1/8 of time
2019-07-18 17:53:52 +00:00
bne alien_no_move_walk
lda alien_direction,X
2019-07-18 17:53:52 +00:00
beq a_walk_left
inc alien_x,X ; walk right
2019-07-18 17:53:52 +00:00
rts
a_walk_left:
dec alien_x,X ; walk left
2019-07-18 17:53:52 +00:00
alien_no_move_walk:
rts
;======================
; running
move_alien_running:
inc alien_gait,X ; cycle through animation
2019-07-18 17:53:52 +00:00
lda alien_gait,X
2019-07-18 17:53:52 +00:00
and #$3
cmp #$2 ; only run roughly 1/4 of time
bne alien_no_move_run
lda alien_direction,X
2019-07-18 17:53:52 +00:00
beq a_run_left
inc alien_x,X ; run right
2019-07-18 17:53:52 +00:00
rts
a_run_left:
dec alien_x,X ; run left
2019-07-18 17:53:52 +00:00
alien_no_move_run:
rts
;======================
; standing
move_alien_standing:
astate_table_lo:
.byte <alien_standing ; 00
.byte <alien_walking ; 01
.byte <alien_running ; 02
.byte <alien_crouching ; 03
2019-07-18 19:29:30 +00:00
.byte <alien_turning ; 04
.byte <alien_yelling ; 05
2019-07-19 00:10:09 +00:00
.byte <alien_shooting_up; 06
2019-07-18 17:53:52 +00:00
astate_table_hi:
2019-07-18 19:29:30 +00:00
.byte >alien_standing ; 00
.byte >alien_walking ; 01
.byte >alien_running ; 02
.byte >alien_crouching ; 03
.byte >alien_turning ; 04
.byte >alien_yelling ; 05
2019-07-19 00:10:09 +00:00
.byte >alien_shooting_up; 06
2019-07-18 17:53:52 +00:00
; Urgh, make sure this doesn't end up at $FF or you hit the
; NMOS 6502 bug
.align 2
ajump:
.word $0000
.align 1
;======================================
; draw alien
;======================================
draw_alien:
; FIXME
ldx #0
lda alien_out,X
2019-07-18 17:53:52 +00:00
beq no_alien
lda alien_state,X
2019-07-18 17:53:52 +00:00
tay
lda astate_table_lo,y
sta ajump
lda astate_table_hi,y
sta ajump+1
jmp (ajump)
no_alien:
rts
;==================================
; STANDING
;==================================
alien_standing:
lda #<alien_stand
sta INL
lda #>alien_stand
sta INH
jmp finally_draw_alien
;===================================
; CROUCHING
;===================================
alien_crouching:
; FIXME: we have an animation?
lda #<alien_crouch2
sta INL
lda #>alien_crouch2
sta INH
jmp finally_draw_alien
;===============================
; Walking
;================================
alien_walking:
lda alien_gait,X
2019-07-18 19:29:30 +00:00
cmp #64
2019-07-18 17:53:52 +00:00
bcc alien_gait_fine ; blt
lda #0
sta alien_gait,X
2019-07-18 17:53:52 +00:00
alien_gait_fine:
2019-07-18 19:29:30 +00:00
lsr
2019-07-18 17:53:52 +00:00
lsr
and #$fe
tay
lda alien_gun,X
2019-07-18 20:18:19 +00:00
beq alien_walk_nogun
alien_walk_gun:
lda alien_walk_gun_progression,Y
sta INL
lda alien_walk_gun_progression+1,Y
sta INH
jmp finally_draw_alien
alien_walk_nogun:
2019-07-18 17:53:52 +00:00
lda alien_walk_progression,Y
sta INL
lda alien_walk_progression+1,Y
sta INH
jmp finally_draw_alien
;===============================
; Running
;================================
alien_running:
lda alien_gait,X
2019-07-18 18:28:06 +00:00
cmp #32
2019-07-18 17:53:52 +00:00
bcc alien_run_gait_fine ; blt
lda #0
sta alien_gait,X
2019-07-18 17:53:52 +00:00
alien_run_gait_fine:
lsr
and #$fe
tay
lda alien_run_progression,Y
sta INL
lda alien_run_progression+1,Y
sta INH
jmp finally_draw_alien
2019-07-18 19:29:30 +00:00
;===============================
; Turning
;================================
alien_turning:
dec alien_gait,X
2019-07-18 19:29:30 +00:00
bpl alien_draw_turning
lda #0
sta alien_gait,X
2019-07-18 19:29:30 +00:00
; switch direction
lda alien_direction,X
2019-07-18 19:29:30 +00:00
eor #$1
sta alien_direction,X
2019-07-18 19:29:30 +00:00
lda #A_WALKING
sta alien_state,X
2019-07-18 19:29:30 +00:00
alien_draw_turning:
lda #<alien_turning_sprite
sta INL
lda #>alien_turning_sprite
sta INH
jmp finally_draw_alien
2019-07-18 17:53:52 +00:00
;===============================
; Yelling
;================================
alien_yelling:
lda alien_gait,X
2019-07-19 00:10:09 +00:00
; 00
; 01
; 10
; 11
and #$40
2019-07-18 23:14:33 +00:00
bne alien_yelling_no_waving
lda alien_gait,X
2019-07-18 23:14:33 +00:00
alien_yelling_no_waving:
and #$10
lsr
lsr
lsr
and #2
2019-07-18 23:14:33 +00:00
tay
lda alien_yell_progression,Y
sta INL
lda alien_yell_progression+1,Y
sta INH
jmp finally_draw_alien
;===============================
; Shooting Upward
;================================
alien_shooting_up:
lda alien_gait,X
2019-07-19 00:10:09 +00:00
and #$30
; 000 000
; 010 000
; 100 000
; 110 000
lsr
lsr
2019-07-19 00:10:09 +00:00
lsr
and #6
tay
lda alien_shoot_up_progression,Y
sta INL
lda alien_shoot_up_progression+1,Y
sta INH
2019-07-19 00:10:09 +00:00
cpy #0
lda alien_gait,X
2019-07-19 01:01:54 +00:00
; and #$ff
2019-07-19 00:10:09 +00:00
bne finally_draw_alien
2019-07-19 01:01:54 +00:00
lda #32
sta SHOOTING_BOTTOM
lda #28
sta SHOOTING_TOP
2019-07-19 00:10:09 +00:00
inc LITTLEGUY_OUT
2019-07-19 00:10:09 +00:00
; bne finally_draw_alien ; bra
2019-07-18 17:53:52 +00:00
;=============================
; Actually Draw Alien
;=============================
finally_draw_alien:
lda alien_x,X
2019-07-18 17:53:52 +00:00
sta XPOS
lda alien_y,X
2019-07-18 17:53:52 +00:00
sta YPOS
lda alien_direction,X
2019-07-18 17:53:52 +00:00
bne alien_facing_right
alien_facing_left:
jmp put_sprite_crop
alien_facing_right:
jmp put_sprite_flipped_crop
;==================
; clear aliens
;==================
clear_aliens:
lda #0
sta alien0_out
sta alien1_out
sta alien2_out
2019-07-18 17:53:52 +00:00
rts