tfv: optimize attack a bit

This commit is contained in:
Vince Weaver 2021-01-18 15:35:12 -05:00
parent 26caa77891
commit d8d2afb366
2 changed files with 35 additions and 29 deletions

View File

@ -5,6 +5,8 @@
attack: attack:
lda #34 lda #34
sta HERO_X sta HERO_X
lda #20
sta HERO_Y
lda #$00 lda #$00
sta DAMAGE_VAL_HI sta DAMAGE_VAL_HI
@ -20,45 +22,24 @@ attack_loop:
; draw hero ; draw hero
lda #20 lda HERO_Y
sta YPOS sta YPOS
lda HERO_X lda HERO_X
sta XPOS sta XPOS
; walk/run alternate frames
lsr lsr
bcc attack_draw_walk bcc attack_draw_walk
attack_draw_stand: attack_draw_stand:
lda #<tfv_stand_left_sprite jsr draw_hero_and_sword
sta INL jmp attack_done_draw
lda #>tfv_stand_left_sprite
jmp attack_actually_draw
attack_draw_walk: attack_draw_walk:
lda #<tfv_walk_left_sprite jsr draw_hero_walk_and_sword
sta INL
lda #>tfv_walk_left_sprite
attack_actually_draw:
sta INH
jsr put_sprite_crop
;========================= attack_done_draw:
; draw sword
lda HERO_X
sec
sbc #5
sta XPOS
; ypos already 20?
lda #<tfv_led_sword_sprite
sta INL
lda #>tfv_led_sword_sprite
sta INH
jsr put_sprite_crop
;========================= ;=========================
@ -85,6 +66,10 @@ attack_actually_draw:
cmp #10 ; repeat until 10 cmp #10 ; repeat until 10
bne attack_loop bne attack_loop
;====================== ;======================
; attack done ; attack done
@ -115,5 +100,3 @@ attack_actually_draw:
sta HERO_X sta HERO_X
rts rts

View File

@ -58,6 +58,28 @@ draw_hero_down:
jmp put_sprite_crop ; tail call jmp put_sprite_crop ; tail call
;============================
; draw hero walk and sword
;============================
; draws at HERO_X,HERO_Y
draw_hero_walk_and_sword:
lda HERO_X
sta XPOS
lda HERO_Y
sta YPOS
lda #<tfv_walk_left_sprite
sta INL
lda #>tfv_walk_left_sprite
sta INH
jsr put_sprite_crop
jmp draw_hero_sword
;============================ ;============================
; draw hero and sword ; draw hero and sword
;============================ ;============================
@ -77,6 +99,7 @@ draw_hero_and_sword:
jsr put_sprite_crop jsr put_sprite_crop
draw_hero_sword:
; grsim_put_sprite(tfv_led_sword,ax-5,20); ; grsim_put_sprite(tfv_led_sword,ax-5,20);
lda HERO_X lda HERO_X
sec sec