peasant: work on unifying the sprite code

This commit is contained in:
Vince Weaver 2021-12-29 01:27:37 -05:00
parent b469b4d564
commit 1ac631bbcf
13 changed files with 242 additions and 186 deletions

View File

@ -119,7 +119,6 @@ qload.inc: generate_common QLOAD
./generate_common -a 0xb00 -s hgr2 qload.lst >> qload.inc
./generate_common -a 0xb00 -s hgr_make_tables qload.lst >> qload.inc
./generate_common -a 0xb00 -s hgr_put_string qload.lst >> qload.inc
./generate_common -a 0xb00 -s save_bg_1x28 qload.lst >> qload.inc
./generate_common -a 0xb00 -s restore_bg_1x28 qload.lst >> qload.inc
./generate_common -a 0xb00 -s hgr_draw_sprite_1x28 qload.lst >> qload.inc
./generate_common -a 0xb00 -s input_buffer qload.lst >> qload.inc

View File

@ -105,12 +105,12 @@ draw_sprite_skip:
rts
.if 0
;======================
; save bg 1x28
;======================
save_bg_1x28:
bsave_bg_1x28:
ldx #0
save_yloop:
@ -142,6 +142,7 @@ save_yloop:
bne save_yloop
rts
.endif
;======================
; restore bg 1x28
@ -149,28 +150,41 @@ save_yloop:
restore_bg_1x28:
ldx #0
restore_yloop:
txa ; current row
clc
adc CURSOR_Y ; add in y start point
; restore bg behind peasant
; is this actually faster than using the generic version?
ldy CURSOR_Y ; y start point
ldx #27 ; height
restore_yloop:
; calc GBASL/GBASH using lookup table
tay
clc
lda hposn_low,Y
sta GBASL
adc PEASANT_X
sta restore_page1_smc+1
sta restore_page2_smc+1
; $40 -> $20 0100 0000 -> 0010 0000
; $41 -> $21 0100 0001 -> 0010 0001
; $51 -> $31 0101 0011 -> 0101 0001
lda hposn_high,Y
sta GBASH
sta restore_page2_smc+2
eor #$60
sta restore_page1_smc+2
ldy CURSOR_X
restore_page1_smc:
lda $DDDD
restore_page2_smc:
sta $DDDD
lda save_sprite_1x28,X
sta (GBASL),Y
iny
inx
cpx #28
bne restore_yloop
dex
bpl restore_yloop
rts
@ -285,9 +299,9 @@ mask_false:
; save area
;====================
save_sprite_1x28:
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
;save_sprite_1x28:
;.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
;.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
ysave:
.byte $00

View File

@ -133,24 +133,46 @@ new_location:
;====================
; save background
lda PEASANT_X
sta CURSOR_X
lda PEASANT_Y
sta CURSOR_Y
; lda PEASANT_X
; sta CURSOR_X
; lda PEASANT_Y
; sta CURSOR_Y
;=======================
; draw initial peasant
jsr save_bg_1x28
; jsr save_bg_1x28
jsr draw_peasant
; jsr draw_peasant
;===========================
;===========================
;===========================
; main loop
;===========================
;===========================
;===========================
game_loop:
;========================
; move the peasant
jsr move_peasant
;========================
; draw the peasant
jsr draw_peasant
;========================
; increment the frame
inc FRAME
;========================
; check the keyboard
jsr check_keyboard
;=====================

View File

@ -14,15 +14,16 @@ peasant_quest_intro:
lda #0
sta ESC_PRESSED
sta LEVEL_OVER
jsr hgr_make_tables
jsr hgr2
;*******************************
;===============================
; restart music, only drum loop
;******************************
;===============================
lda SOUND_STATUS
and #SOUND_MOCKINGBOARD
@ -41,51 +42,51 @@ peasant_quest_intro:
cli
mockingboard_notfound:
;************************
;========================
; Cottage
;************************
;========================
jsr cottage
lda ESC_PRESSED
bne escape_handler
;************************
;========================
; Lake West
;************************
;========================
jsr lake_west
lda ESC_PRESSED
bne escape_handler
;************************
;========================
; Lake East
;************************
;========================
jsr lake_east
lda ESC_PRESSED
bne escape_handler
;************************
;========================
; River
;************************
;========================
jsr river
lda ESC_PRESSED
bne escape_handler
;************************
;========================
; Knight
;************************
;========================
jsr knight
;************************
;========================
; Start actual game
;************************
;========================
jsr draw_peasant
@ -119,9 +120,6 @@ mockingboard_notfound2:
.include "new_game.s"
;.include "wait_keypress.s"
.include "intro_cottage.s"
.include "intro_lake_w.s"
.include "intro_lake_e.s"
@ -130,21 +128,12 @@ mockingboard_notfound2:
.include "draw_peasant.s"
;.include "decompress_fast_v2.s"
;.include "hgr_font.s"
;.include "draw_box.s"
;.include "hgr_rectangle.s"
;.include "hgr_1x28_sprite.s"
;.include "hgr_partial_save.s"
;.include "hgr_input.s"
;.include "hgr_tables.s"
;.include "hgr_text_box.s"
;.include "hgr_hgr2.s"
.include "hgr_1x5_sprite.s"
.include "hgr_sprite.s"
.include "gr_copy.s"
.include "hgr_copy.s"
.include "wait.s"
.include "wait_a_bit.s"

View File

@ -1,11 +1,12 @@
; THATCHED ROOF COTTAGES
; More specifically, the Dashing Residence
cottage:
;************************
;========================
; Cottage
;************************
;========================
lda #0
sta FRAME
@ -22,19 +23,7 @@ cottage:
lda #PEASANT_DIR_RIGHT
sta PEASANT_DIR
;==================
; draw background
lda #<(cottage_lzsa)
sta getsrc_smc+1
lda #>(cottage_lzsa)
sta getsrc_smc+2
lda #$40
jsr decompress_lzsa2_fast
;=============================
; load priority to $400
; indirectly as we can't trash screen holes
@ -52,6 +41,21 @@ cottage:
jsr gr_copy_to_page1
;==========================
; load background to $2000 (PAGE1)
lda #<(cottage_lzsa)
sta getsrc_smc+1
lda #>(cottage_lzsa)
sta getsrc_smc+2
lda #$20
jsr decompress_lzsa2_fast
jsr hgr_copy
;===================
; print title
@ -60,15 +64,15 @@ cottage:
;====================
; save background
lda PEASANT_X
sta CURSOR_X
lda PEASANT_Y
sta CURSOR_Y
; lda PEASANT_X
; sta CURSOR_X
; lda PEASANT_Y
; sta CURSOR_Y
;=======================
; walking
jsr save_bg_1x28
; jsr save_bg_1x28
cottage_walk_loop:
@ -98,20 +102,20 @@ cottage_walk_loop:
sta PEASANT_Y
sta CURSOR_Y
jsr save_bg_1x28
; jsr save_bg_1x28
jsr draw_peasant
;========================
; handle special
;======================
; handle special action
lda FRAME
check_cottage_action1:
cmp #0
bne check_cottage_action2
;========================
; display cottage text 1
lda #<cottage_text1
@ -124,25 +128,30 @@ check_cottage_action2:
cmp #1
bne check_cottage_action3
;=======================
; un-draw the text box
lda #0
ldx #39
jsr hgr_partial_restore
;=======================
; display cottage text 2
lda #<cottage_text2
sta OUTL
lda #>cottage_text2
jmp finish_cottage_action
check_cottage_action3:
cmp #13
bne done_cottage_action
;=========================
; undraw the text box
lda #0
ldx #39
jsr hgr_partial_restore
;=========================
; display cottage text 3
lda #<cottage_text3
@ -155,8 +164,6 @@ finish_cottage_action:
done_cottage_action:
; jsr wait_until_keypress
lda FRAME
@ -262,4 +269,3 @@ cottage_path:
.byte 38,147
.byte $FF,$FF

View File

@ -65,7 +65,7 @@ knight:
;=======================
; walking
jsr save_bg_1x28
; jsr save_bg_1x28
knight_walk_loop:
@ -92,7 +92,7 @@ knight_walk_loop:
sta PEASANT_Y
sta CURSOR_Y
jsr save_bg_1x28
; jsr save_bg_1x28
jsr draw_peasant

View File

@ -1,8 +1,8 @@
; Lake East
;************************
;========================
; Lake East
;************************
;========================
lake_east:
lda #0
sta FRAME
@ -63,7 +63,7 @@ lake_east:
;=======================
; walking
jsr save_bg_1x28
; jsr save_bg_1x28
lake_e_walk_loop:
@ -90,7 +90,7 @@ lake_e_walk_loop:
sta PEASANT_Y
sta CURSOR_Y
jsr save_bg_1x28
; jsr save_bg_1x28
jsr draw_peasant

View File

@ -1,8 +1,11 @@
; Lake West
;************************
; Everyone knows west lake is the best lake
;========================
; Lake West
;************************
;========================
lake_west:
lda #0
sta FRAME
@ -19,24 +22,7 @@ lake_west:
lda #PEASANT_DIR_RIGHT
sta PEASANT_DIR
;==================
; draw background
lda #<(lake_w_lzsa)
sta getsrc_smc+1
lda #>(lake_w_lzsa)
sta getsrc_smc+2
lda #$40
jsr decompress_lzsa2_fast
;================
; print title
jsr intro_print_title
;===============================
; load priority to $400
; indirectly as we can't trash screen holes
@ -54,18 +40,38 @@ lake_west:
jsr gr_copy_to_page1
;==================
; load background
lda #<(lake_w_lzsa)
sta getsrc_smc+1
lda #>(lake_w_lzsa)
sta getsrc_smc+2
lda #$20
jsr decompress_lzsa2_fast
jsr hgr_copy
;================
; print title
jsr intro_print_title
;====================
; save background
lda PEASANT_X
sta CURSOR_X
lda PEASANT_Y
sta CURSOR_Y
; lda PEASANT_X
; sta CURSOR_X
; lda PEASANT_Y
; sta CURSOR_Y
;=======================
; walking
jsr save_bg_1x28
; jsr save_bg_1x28
lake_w_walk_loop:
@ -92,7 +98,7 @@ lake_w_walk_loop:
sta PEASANT_Y
sta CURSOR_Y
jsr save_bg_1x28
; jsr save_bg_1x28
jsr draw_peasant
@ -104,6 +110,7 @@ check_lake_w_action1:
cmp #0
bne check_lake_w_action2
;==========================
; re-display cottage text 3
lda #<cottage_text3
sta OUTL
@ -115,9 +122,17 @@ check_lake_w_action1:
check_lake_w_action2:
cmp #20
bne done_lake_w_action
;=========================
; clear old text
lda #0
ldx #39
jsr hgr_partial_restore
;===========================
; display text
jsr display_lake_w_text1
done_lake_w_action:
@ -126,8 +141,6 @@ done_lake_w_action:
jsr update_bubbles
; jsr wait_until_keypress
lda #3
@ -269,7 +282,7 @@ update_bubbles:
lda #125
sta CURSOR_Y
jsr hgr_draw_sprite_1x5
jsr hgr_draw_sprite ;_1x5
; bubble 3
@ -290,7 +303,7 @@ update_bubbles:
lda #141
sta CURSOR_Y
jsr hgr_draw_sprite_1x5
jsr hgr_draw_sprite ;_1x5
; bubble 4
@ -311,12 +324,7 @@ update_bubbles:
lda #115
sta CURSOR_Y
jsr hgr_draw_sprite_1x5
jsr hgr_draw_sprite ; _1x5
rts
@ -332,45 +340,55 @@ bubble_progress:
.word bubble_sprite5
.include "sprites/bubble_sprites.inc"
.if 0
bubble_sprite0:
.byte $2A
.byte $AA
.byte $2A
.byte $80 ; 1 000 0000
.byte $2A
.byte 1,5
.byte $2A ; 0 010 1010 0 10 10 10 PPPPPPP
.byte $AA ; 1 010 1010 0 +10 10 10 BBBBBBB
.byte $2A ; 0 010 1010 0 10 10 10 PPPPPPP
.byte $80 ; 1 000 0000 0 00 00 00 KKKKKKK
.byte $2A ; 0 010 1010 0 10 10 10 PPPPPPP
bubble_sprite1:
.byte $2A
.byte $AA
.byte $2A
.byte $88 ; 1 XXX 10XX
.byte $22 ; 0 010 XX10
.byte 1,5
.byte $2A ; 0 010 1010 0 10 10 10 PPPPPPP
.byte $AA ; 1 010 1010 0 10 10 10 BBBBBBB
.byte $2A ; 0 010 1010 0 10 10 10 PPPPPPP
.byte $88 ; 1 000 1000 0 00 10 00 KKKBBKK
.byte $22 ; 0 010 0010 0 10 00 10 PPPKKPP
bubble_sprite2:
.byte $2A
.byte $AA
.byte $22 ; 0 010 XX10
.byte $88 ; 1 XXX 10XX
.byte $2A
.byte 1,5
.byte $2A ; 0 010 1010 0 10 10 10 PPPPPPP
.byte $AA ; 1 010 1010 0 10 10 10 BBBBBBB
.byte $22 ; 0 010 0010 0 10 00 10 PPPKKPP
.byte $88 ; 1 000 1000 0 00 10 00 KKKBBKK
.byte $2A ; 0 010 1010 0 10 10 10 PPPPPPP
bubble_sprite3:
.byte $2A
.byte $A2 ; 101X XX10
.byte $08 ; 00XX 1XX0
.byte $88 ; 1XX0 10XX
.byte $2A
.byte 1,5
.byte $2A ; 0 010 1010 0 10 10 10 PPPPPPP
.byte $A2 ; 1 010 0010 0 10 00 10 BBBKKBB
.byte $08 ; 0 000 1000 0 00 10 00 KKKPPKK
.byte $88 ; 1 000 1000 0 00 10 00 KKKBBKK
.byte $2A ; 0 010 1010 0 10 10 10 PPPPPPP
bubble_sprite4:
.byte $08 ; 0xx0 10xx
.byte $A2 ; 101x xx10
.byte $08 ; 00xx 1xx0
.byte $88 ; 1xx0 10XX
.byte $2A ; 0010 1010
.byte 1,5
.byte $08 ; 0000 1000 0 00 10 00 KKKPPKK
.byte $A2 ; 1010 0010 0 10 00 10 BBBKKBB
.byte $08 ; 0000 1000 0 00 10 00 KKKPPKK
.byte $88 ; 1000 1000 0 00 10 00 KKKBBKK
.byte $2A ; 0010 1010 0 10 10 10 PPPPPPP
bubble_sprite5:
.byte $2A ; 0010 1010
.byte $88 ; 1XX0 10XX
.byte $22 ; 001X XX10
.byte $88 ; 1XX0 10XX
.byte $2A ; 0010 1010
.byte 1,5
.byte $2A ; 0010 1010 0 10 10 10 PPPPPPP
.byte $88 ; 1000 1000 0 00 10 00 KKKBBKK
.byte $22 ; 0010 0010 0 10 00 10 PPPKKPP
.byte $88 ; 1000 1000 0 00 10 00 KKKBBKK
.byte $2A ; 0010 1010 0 10 10 10 PPPPPPP
.endif

View File

@ -65,7 +65,7 @@ river:
;=======================
; walking
jsr save_bg_1x28
; jsr save_bg_1x28
river_walk_loop:
@ -92,7 +92,7 @@ river_walk_loop:
sta PEASANT_Y
sta CURSOR_Y
jsr save_bg_1x28
; jsr save_bg_1x28
jsr draw_peasant

View File

@ -231,7 +231,7 @@ ned_cottage_rock_not_moved:
lda PEASANT_Y
sta CURSOR_Y
jsr save_bg_1x28
; jsr save_bg_1x28
jsr draw_peasant

View File

@ -3,38 +3,37 @@ sector_write =$0c63
requested_sector =$0d17
decompress_lzsa2_fast =$0de6
getsrc_smc =$0edc
hgr2 =$183f
hgr_make_tables =$15b3
hgr2 =$180a
hgr_make_tables =$157e
hgr_put_string =$0ee9
save_bg_1x28 =$1421
restore_bg_1x28 =$1442
restore_bg_1x28 =$1421
hgr_draw_sprite_1x28 =$13ba
input_buffer =$158b
hgr_text_box =$1629
hgr_text_box_nosave =$16c0
hgr_partial_restore =$1501
clear_bottom =$1814
hgr_input =$1531
input_buffer =$1556
hgr_text_box =$15f4
hgr_text_box_nosave =$168b
hgr_partial_restore =$14cc
clear_bottom =$17df
hgr_input =$14fc
draw_box =$126b
disp_put_string =$1664
disp_one_line =$1678
disp_put_string =$162f
disp_one_line =$1643
invert_smc1 =$0f61
disp_put_string_cursor =$1674
disp_put_string_cursor =$163f
hgr_put_char_cursor =$0f15
vgi_simple_rectangle =$12ec
peasant_text =$1f73
save_menu =$18f2
load_menu =$18e7
location_names_l =$1c1f
location_names_h =$1c3e
wait_until_keypress =$1e5e
random16 =$1e67
score_points =$1eec
print_score =$1e9c
update_score =$1ea7
speaker_beep =$1f5a
speaker_duration =$1f71
speaker_frequency =$1f72
peasant_text =$1f3e
save_menu =$18bd
load_menu =$18b2
location_names_l =$1bea
location_names_h =$1c09
wait_until_keypress =$1e29
random16 =$1e32
score_points =$1eb7
print_score =$1e67
update_score =$1e72
speaker_beep =$1f25
speaker_duration =$1f3c
speaker_frequency =$1f3d
hposn_high = $BA00
hposn_low = $BB00
driveoff = $A22

View File

@ -3,7 +3,7 @@ HGR_SPRITE = ../../../utils/hgr-utils/hgr_make_sprite
all: inventory_sprites.inc ending_sprites.inc trogdor_sprites.inc \
boat_sprites.inc peasant_sprites.inc ned_sprites.inc \
peasant_robe_sprites.inc kerrek_sprites.inc \
waterfall_sprites.inc
waterfall_sprites.inc bubble_sprites.inc
peasant_sprites.inc: peasant_sprites.png
$(HGR_SPRITE) -l peasant_right1_sprite peasant_sprites.png 35 1 35 29 > peasant_sprites.inc
@ -156,9 +156,18 @@ trogdor_sprites.inc: trogdor_sprites.png
waterfall_sprites.inc: waterfall_sprites.png
$(HGR_SPRITE) -s -l waterfall_sprite waterfall_sprites.png 14 5 27 52 > waterfall_sprites.inc
bubble_sprites.inc: bubble_sprites.png
$(HGR_SPRITE) -s -l bubble_sprite0 bubble_sprites.png 7 1 13 6 > bubble_sprites.inc
$(HGR_SPRITE) -s -l bubble_sprite1 bubble_sprites.png 7 8 13 13 >> bubble_sprites.inc
$(HGR_SPRITE) -s -l bubble_sprite2 bubble_sprites.png 7 15 13 20 >> bubble_sprites.inc
$(HGR_SPRITE) -s -l bubble_sprite3 bubble_sprites.png 7 22 13 27 >> bubble_sprites.inc
$(HGR_SPRITE) -s -l bubble_sprite4 bubble_sprites.png 7 29 13 34 >> bubble_sprites.inc
$(HGR_SPRITE) -s -l bubble_sprite5 bubble_sprites.png 7 36 13 41 >> bubble_sprites.inc
clean:
rm -f *~ peasant_sprites.inc inventory_sprites.inc \
ending_sprites.inc trogdor_sprites.inc ned_sprites.inc \
peasant_robe_sprites.inc kerrek_sprites.inc \
waterfall_sprites.inc
waterfall_sprites.inc bubble_sprites.inc

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB