ootw: add initial alien sprites

This commit is contained in:
Vince Weaver 2019-07-18 13:53:52 -04:00
parent 105303e239
commit 6244587ac6
5 changed files with 582 additions and 5 deletions

View File

@ -56,9 +56,10 @@ OOTW_C2: ootw_c2.o
ootw_c2.o: ootw_c2.s \
gr_copy.s gr_copy_offset.s gr_fast_clear.s gr_pageflip.s gr_unrle.s \
gr_putsprite.s gr_putsprite_flipped.s gr_putsprite_crop.s \
keyboard.s gr_run_sequence.s physicist.s \
keyboard.s gr_run_sequence.s physicist.s alien.s \
ootw_c2_miners.s \
ootw_graphics/sprites/sprites_physicist.inc \
ootw_graphics/sprites/sprites_alien.inc \
ootw_c2_cage.s ootw_c2_jail.s ootw_c2_elevator.s ootw_c2_intro.s \
ootw_graphics/cage/ootw_c2_cage.inc \
ootw_graphics/l2intro/ootw_l2intro.inc

254
ootw/alien.s Normal file
View File

@ -0,0 +1,254 @@
; draw/move the bad guy aliens
alien_state:
alien0:
alien0_out: .byte 0
alien0_x: .byte 0
alien0_y: .byte 0
alien0_state: .byte 0
alien0_gait: .byte 0
alien0_direction: .byte 0
alien1:
alien1_out: .byte 0
alien1_x: .byte 0
alien1_y: .byte 0
alien1_state: .byte 0
alien1_gait: .byte 0
alien1_direction: .byte 0
ALIEN_OUT = 0
ALIEN_X = 1
ALIEN_Y = 2
ALIEN_STATE = 3
ALIEN_GAIT = 4
ALIEN_DIRECTION = 5
A_STANDING = 0
A_WALKING = 1
A_RUNNING = 2
A_CROUCHING = 3
;=======================================
; Move alien based on current state
;
move_alien:
; FIXME: loop through all alieans
ldx #0
lda alien_state+ALIEN_OUT,X
beq done_move_alien
lda alien_state+ALIEN_STATE,X
cmp #P_WALKING
beq move_alien_walking
cmp #P_RUNNING
beq move_alien_running
done_move_alien:
rts
;======================
; walking
move_alien_walking:
inc alien_state+ALIEN_GAIT,X ; cycle through animation
lda alien_state+ALIEN_GAIT,X
and #$7
cmp #$4 ; only walk roughly 1/8 of time
bne alien_no_move_walk
lda alien_state+ALIEN_DIRECTION,X
beq a_walk_left
inc alien_state+ALIEN_X,X ; walk right
rts
a_walk_left:
dec alien_state+ALIEN_X,X ; walk left
alien_no_move_walk:
rts
;======================
; running
move_alien_running:
inc alien_state+ALIEN_GAIT,X ; cycle through animation
lda alien_state+ALIEN_GAIT,X
and #$3
cmp #$2 ; only run roughly 1/4 of time
bne alien_no_move_run
lda alien_state+ALIEN_DIRECTION,X
beq a_run_left
inc alien_state+ALIEN_X,X ; run right
rts
a_run_left:
dec alien_state+ALIEN_X,X ; run left
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
astate_table_hi:
.byte >alien_standing
.byte >alien_walking
.byte >alien_running
.byte >alien_crouching
; 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_state+ALIEN_OUT,X
beq no_alien
lda alien_state+ALIEN_STATE,X
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_state+ALIEN_GAIT,X
cmp #40
bcc alien_gait_fine ; blt
lda #0
sta alien_state+ALIEN_GAIT,X
alien_gait_fine:
lsr
and #$fe
tay
lda alien_walk_progression,Y
sta INL
lda alien_walk_progression+1,Y
sta INH
jmp finally_draw_alien
;===============================
; Running
;================================
alien_running:
lda alien_state+ALIEN_GAIT,X
cmp #40
bcc alien_run_gait_fine ; blt
lda #0
sta alien_state+ALIEN_GAIT,X
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
;=============================
; Actually Draw Alien
;=============================
finally_draw_alien:
lda alien_state+ALIEN_X,X
sta XPOS
lda alien_state+ALIEN_Y,X
sta YPOS
lda alien_state+ALIEN_DIRECTION,X
bne alien_facing_right
alien_facing_left:
jmp put_sprite_crop
alien_facing_right:
jmp put_sprite_flipped_crop

View File

@ -134,7 +134,6 @@ end_message:
.include "ootw_c2_jail.s"
.include "ootw_c2_elevator.s"
.include "ootw_c2_intro.s"
.include "physicist.s"
.include "text_print.s"
.include "gr_pageflip.s"
.include "gr_unrle.s"
@ -151,6 +150,9 @@ end_message:
.include "random16.s"
.include "keyboard.s"
.include "physicist.s"
.include "alien.s"
; background miners
.include "ootw_c2_miners.s"
@ -159,6 +161,7 @@ end_message:
.include "ootw_graphics/l2jail/ootw_c2_jail.inc"
; sprites
.include "ootw_graphics/sprites/sprites_physicist.inc"
.include "ootw_graphics/sprites/sprites_alien.inc"
; intro
.include "ootw_graphics/l2intro/ootw_l2intro.inc"
; city movie

View File

@ -121,7 +121,9 @@ done_drawing_cage:
lda CAGE_GUARD
cmp #15
bcs guard_changed
bcs guard_patrol ; bge
; guard changing uniform
lda #34
sta XPOS
@ -142,9 +144,19 @@ done_drawing_cage:
; inc CAGE_GUARD
jmp done_cage_guard
guard_changed:
; other guard activity
guard_patrol:
; guard patroling
jsr draw_alien
guard_shooting:
; guard shooting
done_cage_guard:
@ -207,7 +219,39 @@ no_move_cage:
and #$f
bne no_move_cage_guard
lda CAGE_GUARD
cmp #16
bcs guard_done_change
guard_blah:
inc CAGE_GUARD
jmp no_move_cage_guard
guard_done_change:
cmp #16
bne no_move_cage_guard
; start patrol
lda #1
sta alien0_out
lda #34
sta alien0_x
lda #30
sta alien0_y
lda #A_WALKING
sta alien0_state
lda #0
sta alien0_gait
lda #0
sta alien0_direction
no_move_cage_guard:

View File

@ -0,0 +1,275 @@
; note, for some reason these are all facing left
;=====================
;=====================
; STANDING
;=====================
;=====================
;====================
; Going Left
alien_stand:
.byte $5,$8
.byte $aa,$9a,$9a,$aa,$aa
.byte $aa,$bb,$99,$aa,$aa
.byte $aa,$aa,$0b,$aa,$aa
.byte $aa,$aa,$bb,$aa,$aa
.byte $aa,$aa,$bb,$aa,$aa
.byte $aa,$aa,$44,$aa,$aa
.byte $aa,$aa,$44,$aa,$aa
.byte $aa,$fa,$f4,$aa,$aa
;=====================
;=====================
; WALKING
;=====================
;=====================
alien_walk_progression:
.word alien_walk_left1
.word alien_walk_left2
.word alien_walk_left3
.word alien_walk_left4
.word alien_walk_left5
.word alien_walk_left6
.word alien_walk_left7
.word alien_walk_left8
alien_walk_left1:
.byte $5,$8
.byte $aa,$7a,$57,$75,$aa
.byte $aa,$77,$07,$00,$aa
.byte $aa,$5a,$00,$77,$aa
.byte $aa,$55,$10,$77,$aa
.byte $aa,$aa,$00,$07,$aa
.byte $aa,$aa,$77,$a5,$5a
.byte $aa,$aa,$07,$aa,$05
.byte $aa,$a0,$00,$0a,$00
alien_walk_left2:
.byte $5,$8
.byte $aa,$7a,$57,$75,$aa
.byte $aa,$77,$07,$00,$aa
.byte $aa,$aa,$00,$77,$aa
.byte $aa,$5a,$77,$17,$aa
.byte $aa,$aa,$07,$00,$aa
.byte $aa,$aa,$77,$55,$aa
.byte $aa,$aa,$07,$aa,$05
.byte $aa,$0a,$00,$00,$a0
alien_walk_left3:
.byte $5,$8
.byte $aa,$7a,$57,$75,$aa
.byte $aa,$77,$07,$00,$aa
.byte $aa,$aa,$00,$77,$aa
.byte $aa,$aa,$77,$10,$aa
.byte $aa,$aa,$07,$00,$aa
.byte $aa,$aa,$77,$55,$aa
.byte $aa,$aa,$07,$00,$0a
.byte $aa,$0a,$00,$aa,$a0
alien_walk_left4:
.byte $5,$8
.byte $aa,$7a,$57,$75,$aa
.byte $aa,$77,$07,$00,$aa
.byte $aa,$aa,$00,$77,$aa
.byte $aa,$aa,$77,$10,$aa
.byte $aa,$a5,$00,$00,$aa
.byte $aa,$aa,$77,$55,$aa
.byte $aa,$aa,$07,$05,$aa
.byte $aa,$0a,$00,$00,$aa
alien_walk_left5:
.byte $5,$8
.byte $aa,$7a,$57,$75,$aa
.byte $aa,$77,$07,$00,$aa
.byte $aa,$aa,$00,$77,$aa
.byte $aa,$aa,$77,$10,$aa
.byte $aa,$a5,$00,$00,$aa
.byte $aa,$5a,$55,$77,$aa
.byte $aa,$00,$a7,$07,$aa
.byte $a0,$a0,$0a,$00,$aa
alien_walk_left6:
.byte $5,$8
.byte $aa,$7a,$57,$75,$aa
.byte $aa,$77,$07,$00,$aa
.byte $aa,$aa,$00,$77,$aa
.byte $aa,$aa,$77,$17,$5a
.byte $aa,$aa,$07,$00,$a5
.byte $aa,$5a,$55,$77,$7a
.byte $aa,$05,$aa,$aa,$07
.byte $a0,$a0,$aa,$0a,$00
alien_walk_left7:
.byte $5,$8
.byte $aa,$7a,$57,$75,$aa
.byte $aa,$77,$07,$00,$aa
.byte $aa,$aa,$00,$77,$aa
.byte $aa,$aa,$10,$77,$aa
.byte $aa,$aa,$00,$07,$aa
.byte $aa,$aa,$57,$77,$aa
.byte $aa,$aa,$05,$a7,$07
.byte $aa,$0a,$00,$00,$a0
alien_walk_left8:
.byte $5,$8
.byte $5,$8
.byte $aa,$7a,$57,$75,$aa
.byte $aa,$77,$07,$00,$aa
.byte $aa,$aa,$00,$77,$aa
.byte $aa,$5a,$10,$77,$7a
.byte $aa,$a5,$00,$00,$a7
.byte $aa,$aa,$55,$77,$aa
.byte $aa,$aa,$a5,$07,$aa
.byte $aa,$aa,$00,$00,$aa
;=====================
;=====================
; RUNNING
;=====================
;=====================
alien_run_progression:
.word alien_run_left1
.word alien_run_left2
.word alien_run_left3
.word alien_run_left4
.word alien_run_left5
.word alien_run_left6
.word alien_run_left7
.word alien_run_left8
alien_run_left1:
.byte $5,$8
.byte $aa,$9a,$9a,$aa,$aa
.byte $aa,$bb,$99,$aa,$aa
.byte $aa,$aa,$0b,$aa,$aa
.byte $aa,$aa,$bb,$aa,$aa
.byte $aa,$ba,$0b,$aa,$aa
.byte $aa,$aa,$44,$aa,$aa
.byte $aa,$aa,$44,$ac,$77
.byte $aa,$fa,$f4,$aa,$aa
alien_run_left2:
.byte $5,$8
.byte $aa,$9a,$9a,$aa,$aa
.byte $aa,$bb,$99,$aa,$aa
.byte $aa,$aa,$0b,$aa,$aa
.byte $aa,$aa,$bb,$aa,$aa
.byte $ba,$ab,$00,$aa,$aa
.byte $aa,$ca,$44,$aa,$aa
.byte $aa,$ac,$44,$4a,$aa
.byte $aa,$aa,$fa,$f4,$aa
alien_run_left3:
.byte $5,$8
.byte $aa,$9a,$9a,$aa,$aa
.byte $aa,$bb,$99,$aa,$aa
.byte $aa,$aa,$0b,$aa,$aa
.byte $aa,$aa,$bb,$aa,$aa
.byte $ab,$ab,$00,$aa,$aa
.byte $aa,$ca,$44,$aa,$aa
.byte $aa,$cc,$a4,$4a,$aa
.byte $a7,$a7,$fa,$af,$aa
alien_run_left4:
.byte $5,$8
.byte $aa,$9a,$9a,$aa,$aa
.byte $aa,$bb,$99,$aa,$aa
.byte $aa,$aa,$0b,$aa,$aa
.byte $ba,$ba,$0b,$aa,$aa
.byte $aa,$ab,$00,$aa,$aa
.byte $aa,$ca,$44,$aa,$aa
.byte $aa,$cc,$aa,$44,$aa
.byte $7a,$a7,$aa,$fa,$af
alien_run_left5:
.byte $5,$8
.byte $aa,$9a,$9a,$aa,$aa
.byte $aa,$bb,$99,$aa,$aa
.byte $aa,$aa,$0b,$aa,$aa
.byte $aa,$aa,$bb,$aa,$aa
.byte $aa,$ab,$0b,$aa,$aa
.byte $aa,$aa,$44,$4a,$fa
.byte $aa,$cc,$aa,$aa,$af
.byte $7a,$7c,$aa,$aa,$aa
alien_run_left6:
.byte $5,$8
.byte $aa,$9a,$9a,$aa,$aa
.byte $aa,$bb,$99,$aa,$aa
.byte $aa,$aa,$0b,$aa,$aa
.byte $aa,$aa,$bb,$aa,$aa
.byte $aa,$ab,$00,$aa,$aa
.byte $aa,$aa,$44,$4a,$fa
.byte $aa,$aa,$cc,$aa,$af
.byte $aa,$7a,$7c,$aa,$aa
alien_run_left7:
.byte $5,$8
.byte $aa,$9a,$9a,$aa,$aa
.byte $aa,$bb,$99,$aa,$aa
.byte $aa,$aa,$0b,$aa,$aa
.byte $aa,$aa,$bb,$aa,$aa
.byte $aa,$ab,$0b,$aa,$aa
.byte $aa,$4a,$44,$aa,$aa
.byte $aa,$a4,$c4,$ff,$aa
.byte $aa,$7a,$7c,$aa,$aa
alien_run_left8:
.byte $5,$8
.byte $aa,$9a,$9a,$aa,$aa
.byte $aa,$bb,$99,$aa,$aa
.byte $aa,$aa,$0b,$aa,$aa
.byte $aa,$ba,$bb,$aa,$aa
.byte $aa,$aa,$0b,$ba,$aa
.byte $aa,$4a,$44,$aa,$aa
.byte $aa,$44,$ac,$ca,$aa
.byte $af,$af,$7a,$7c,$aa
;=====================
;=====================
; JUMPING
;=====================
;=====================
;=====================
;=====================
; CROUCHING
;=====================
;=====================
alien_crouch_progression:
.word alien_crouch1
.word alien_crouch2
alien_crouch1:
.byte $3,$8
.byte $aa,$aa,$aa
.byte $9a,$9a,$aa
.byte $bb,$99,$aa
.byte $aa,$0b,$aa
.byte $aa,$bb,$aa
.byte $aa,$bb,$aa
.byte $44,$44,$aa
.byte $5a,$fc,$f4
alien_crouch2:
.byte $3,$8
.byte $aa,$aa,$aa
.byte $aa,$aa,$aa
.byte $9a,$9a,$aa
.byte $bb,$99,$aa
.byte $aa,$0b,$0a
.byte $aa,$bb,$00
.byte $ba,$4b,$aa
.byte $54,$f4,$f4