peasant: start moving to new background drawing code

might be workable, makes animations much easier
This commit is contained in:
Vince Weaver 2021-12-27 01:19:48 -05:00
parent bde1864ac2
commit 39c9c38bbf
12 changed files with 128 additions and 67 deletions

View File

@ -13,6 +13,7 @@ hgr_partial_save:
ldx BOX_Y2
stx SAVED_Y2
.if 0
partial_save_yloop:
lda hposn_low,X
@ -37,7 +38,7 @@ psx_smc2:
dex
cpx BOX_Y1
bcs partial_save_yloop
.endif
rts
@ -48,7 +49,12 @@ psx_smc2:
; loads from $20
; save to $40
; restores from X = A<=to<=X
; Y = SAVED_Y1 to SAVED_Y2
hgr_partial_restore:
sta partial_restore_x1_smc+1
stx partial_restore_x2_smc+1
ldx SAVED_Y2
@ -64,6 +70,7 @@ partial_restore_yloop:
sbc #$20
sta prx_smc1+2
partial_restore_x2_smc:
ldy #$27
partial_restore_xloop:
prx_smc1:
@ -71,6 +78,8 @@ prx_smc1:
prx_smc2:
sta $d000,Y
dey
partial_restore_x1_smc:
cpy #$00
bpl partial_restore_xloop
dex

View File

@ -1,3 +1,4 @@
.if 0
;=======================
; HGR Save
;=======================
@ -231,3 +232,4 @@ hgr_restore_loop:
hgr_restore_done:
rts
.endif

View File

@ -123,6 +123,9 @@ check_cottage_action1:
check_cottage_action2:
cmp #1
bne check_cottage_action3
lda #0
ldx #39
jsr hgr_partial_restore
; display cottage text 2
@ -136,6 +139,8 @@ check_cottage_action2:
check_cottage_action3:
cmp #13
bne done_cottage_action
lda #0
ldx #39
jsr hgr_partial_restore
; display cottage text 3

View File

@ -116,6 +116,8 @@ check_knight_action1:
check_knight_action2:
cmp #8
bne check_knight_action3
lda #0
ldx #39
jsr hgr_partial_restore
jmp done_knight_action

View File

@ -111,6 +111,8 @@ check_lake_e_action1:
check_lake_e_action2:
cmp #28
bne done_lake_e_action
lda #0
ldx #39
jsr hgr_partial_restore
lda #PEASANT_DIR_UP
sta PEASANT_DIR

View File

@ -115,6 +115,8 @@ check_lake_w_action1:
check_lake_w_action2:
cmp #20
bne done_lake_w_action
lda #0
ldx #39
jsr hgr_partial_restore
jsr display_lake_w_text1

View File

@ -30,6 +30,23 @@ kerrek_no_draw:
kerrek_actually_draw:
;=================
; erase old kerrek
;=================
lda PREV_Y
sta SAVED_Y1
clc
adc #51
sta SAVED_Y2
lda PREV_X
tax
inx
inx
jsr hgr_partial_restore
;=================
; draw kerrek body
;=================
@ -38,7 +55,8 @@ kerrek_actually_draw:
beq kerrek_draw_body_left
kerrek_draw_body_right:
lda KERREK_X
ldx KERREK_X
txa
and #1
beq kerrek_draw_body_right_even
@ -58,26 +76,28 @@ kerrek_draw_body_right_even:
kerrek_draw_body_left:
ldx KERREK_X
inx
lda KERREK_X
and #1
beq kerrek_draw_body_left_even
kerrek_draw_body_left_odd:
lda #<kerrek_l2_sprite
sta INL
lda #>kerrek_l2_sprite
jmp kerrek_draw_body_common
kerrek_draw_body_left_even:
lda #<kerrek_l1_sprite
sta INL
lda #>kerrek_l1_sprite
jmp kerrek_draw_body_common
kerrek_draw_body_left_even:
lda #<kerrek_l2_sprite
sta INL
lda #>kerrek_l2_sprite
kerrek_draw_body_common:
sta INH
lda KERREK_X
sta CURSOR_X
stx CURSOR_X
lda KERREK_Y
sta CURSOR_Y
@ -132,22 +152,21 @@ kerrek_draw_head_left:
kerrek_draw_head_left_odd:
lda #<kerrek_l2_head_sprite
lda #<kerrek_l1_head_sprite
sta INL
lda #>kerrek_l2_head_sprite
lda #>kerrek_l1_head_sprite
jmp kerrek_draw_head_left_common
kerrek_draw_head_left_even:
lda #<kerrek_l1_head_sprite
lda #<kerrek_l2_head_sprite
sta INL
lda #>kerrek_l1_head_sprite
lda #>kerrek_l2_head_sprite
kerrek_draw_head_left_common:
sta INH
ldx KERREK_X
dex
kerrek_draw_head_common:
stx CURSOR_X
@ -182,8 +201,10 @@ kerrek_alive_out:
lda #22
sta KERREK_X
sta PREV_X
lda #76
sta KERREK_Y
sta PREV_Y
lda #1 ; right
sta KERREK_DIRECTION
lda #1
@ -301,6 +322,12 @@ kerrek_move:
and #$1
bne kerrek_move_done
; save old values
lda KERREK_X
sta PREV_X
lda KERREK_Y
sta PREV_Y
; if kerrek_x > peasant_x, kerrek_x--
; if kerrek_x < peasant_x, kerrek_x++
@ -349,20 +376,18 @@ kerrek_check_collision:
; first check X
; if (peasant_x >= kerrek_x-1) && (peasant_x<=kerrek_x+2)
; this is roughly equivelant to |kerrek_x-peasant_x| < 2
; if (peasant_x >= kerrek_x) && (peasant_x<=kerrek_x+2)
lda PEASANT_X
cmp KERREK_X
bcc kerrek_no_collision
lda KERREK_X
sec
sbc PEASANT_X
bpl kerrek_x_distance_good
kerrek_x_distance_negate:
eor #$FF
clc
adc #1
kerrek_x_distance_good:
cmp #2
bcs kerrek_no_collision
lda KERREK_X
adc #2
cmp PEASANT_X
bcc kerrek_no_collision
; next check Y

View File

@ -717,6 +717,8 @@ finish_parse_message:
restore_parse_message:
lda #0
ldx #39
jsr hgr_partial_restore
@ -1223,6 +1225,8 @@ partial_message_step:
sty OUTH
jsr print_text_message
jsr wait_until_keypress
lda #0
ldx #39
jsr hgr_partial_restore
rts

View File

@ -71,22 +71,7 @@ new_location:
jsr load_custom_verb_table
;=====================
; load bg
; we are PEASANT1 so locations 0...4 map to 0...4, no change
ldx MAP_LOCATION
lda map_backgrounds_low,X
sta getsrc_smc+1
lda map_backgrounds_hi,X
sta getsrc_smc+2
lda #$40
jsr decompress_lzsa2_fast
;===========================
; load priority to $400
; indirectly as we can't trash screen holes
@ -107,6 +92,25 @@ new_location:
jsr gr_copy_to_page1
;=====================
; load bg
; we are PEASANT1 so locations 0...4 map to 0...4, no change
ldx MAP_LOCATION
lda map_backgrounds_low,X
sta getsrc_smc+1
lda map_backgrounds_hi,X
sta getsrc_smc+2
lda #$20
jsr decompress_lzsa2_fast
; copy to $4000
jsr hgr_copy
; put peasant text
@ -172,6 +176,7 @@ game_loop:
jsr check_keyboard
; FIXME: draw kerrek before peasant if behind him
jsr kerrek_draw
jsr kerrek_move_and_check_collision
@ -269,6 +274,7 @@ game_over:
;.include "hgr_hgr2.s"
;.include "wait_keypress.s"
;.include "loadsave_menu.s"
.include "hgr_copy.s"
;.include "text/peasant1.inc"

View File

@ -3,39 +3,39 @@ sector_write =$0c63
requested_sector =$0d17
decompress_lzsa2_fast =$0de6
getsrc_smc =$0edc
hgr2 =$1861
hgr_make_tables =$15da
hgr2 =$1844
hgr_make_tables =$15bd
hgr_put_string =$0ee9
save_bg_1x28 =$1421
restore_bg_1x28 =$1442
hgr_draw_sprite_1x28 =$13ba
input_buffer =$15b2
hgr_text_box =$1650
hgr_text_box_nosave =$16e2
hgr_partial_restore =$1530
clear_bottom =$1836
hgr_input =$1558
input_buffer =$1595
hgr_text_box =$1633
hgr_text_box_nosave =$16c5
hgr_partial_restore =$150b
clear_bottom =$1819
hgr_input =$153b
hgr_partial_save =$1501
draw_box =$126b
disp_put_string =$1686
disp_one_line =$169a
disp_put_string =$1669
disp_one_line =$167d
invert_smc1 =$0f61
disp_put_string_cursor =$1696
disp_put_string_cursor =$1679
hgr_put_char_cursor =$0f15
vgi_simple_rectangle =$12ec
peasant_text =$1f94
save_menu =$1914
load_menu =$1909
location_names_l =$1c40
location_names_h =$1c5f
wait_until_keypress =$1e7f
random16 =$1e88
score_points =$1f0d
print_score =$1ebd
update_score =$1ec8
speaker_beep =$1f7b
speaker_duration =$1f92
speaker_frequency =$1f93
peasant_text =$1f77
save_menu =$18f7
load_menu =$18ec
location_names_l =$1c23
location_names_h =$1c42
wait_until_keypress =$1e62
random16 =$1e6b
score_points =$1ef0
print_score =$1ea0
update_score =$1eab
speaker_beep =$1f5e
speaker_duration =$1f75
speaker_frequency =$1f76
hposn_high = $BA00
hposn_low = $BB00
driveoff = $A22

View File

@ -487,6 +487,8 @@ skip_speech:
jsr wait_until_keypress
done_speech:
lda #0
ldx #39
jsr hgr_partial_restore
rts

View File

@ -238,6 +238,8 @@ SAVED_Y2 = $C8
; temp for animations, etc
BABY_COUNT = $C9
PREV_X = $CA
PREV_Y = $CB
; D0-D? used by HGR?