peasant: make hgr_text_box routine

optimizes things, though only saves 100 bytes or so
This commit is contained in:
Vince Weaver 2021-08-14 21:10:56 -04:00
parent 60a5c525f8
commit 707fc5de7d
9 changed files with 184 additions and 257 deletions

View File

@ -71,7 +71,7 @@ INTRO: intro.o
intro.o: intro.s graphics/graphics.inc sprites/peasant_sprite.inc \
draw_box.s hgr_rectangle.s hgr_font.s hgr_input.s \
hgr_7x30_sprite.s hgr_1x5_sprite.s hgr_save_restore.s \
wait_a_bit.s draw_peasant.s \
wait_a_bit.s draw_peasant.s hgr_text_box.s \
title.s directions.s \
intro_cottage.s intro_lake_w.s intro_lake_e.s \
intro_river.s intro_knight.s

View File

@ -0,0 +1,88 @@
;===========================
; hgr text box
;===========================
; point OUTL:OUTH at it
; x1h,x1l,y1 x2h,x2l,y2
; then X,Y of text
; CR moves to next line
; 0 ends
hgr_text_box:
ldy #0
;====================
; draw text box
lda (OUTL),Y
sta BOX_X1H
iny
lda (OUTL),Y
sta BOX_X1L
iny
lda (OUTL),Y
sta BOX_Y1
iny
lda (OUTL),Y
sta BOX_X2H
iny
lda (OUTL),Y
sta BOX_X2L
iny
lda (OUTL),Y
sta BOX_Y2
jsr draw_box
clc
lda OUTL
adc #6
sta OUTL
lda OUTH
adc #0
sta OUTH
;
;
;
ldy #0
lda (OUTL),Y
sta CURSOR_X
sta SAVED_X
jsr inc_outl
lda (OUTL),Y
sta CURSOR_Y
jsr inc_outl
disp_put_string_loop:
ldy #0
lda (OUTL),Y
beq disp_put_string_done
cmp #13
beq disp_end_of_line
jsr hgr_put_char_cursor
inc CURSOR_X
jsr inc_outl
jmp disp_put_string_loop
disp_end_of_line:
clc
lda CURSOR_Y
adc #8
sta CURSOR_Y
lda SAVED_X
sta CURSOR_X
jsr inc_outl
jmp disp_put_string_loop
disp_put_string_done:
rts

View File

@ -94,6 +94,7 @@ peasant_quest:
.include "hgr_save_restore.s"
.include "hgr_input.s"
.include "hgr_tables.s"
.include "hgr_text_box.s"
.include "wait_a_bit.s"

View File

@ -1,4 +1,5 @@
; THATCHED ROOF COTTAGES
; More specifically, the Dashing Residence
cottage:
@ -65,21 +66,42 @@ cottage_walk_loop:
check_cottage_action1:
cmp #0
bne check_cottage_action2
jsr display_cottage_text1
jmp done_cottage_action
; display cottage text 1
lda #<cottage_text1
sta OUTL
lda #>cottage_text1
jmp finish_cottage_action
check_cottage_action2:
cmp #1
bne check_cottage_action3
jsr hgr_restore
jsr display_cottage_text2
jmp done_cottage_action
; 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
jsr hgr_restore
jsr display_cottage_text3
; display cottage text 3
lda #<cottage_text3
sta OUTL
lda #>cottage_text3
finish_cottage_action:
sta OUTH
jsr hgr_text_box
done_cottage_action:
@ -131,150 +153,44 @@ done_cottage:
rts
;============================
; display cottage text 1
;============================
display_cottage_text1:
;====================
; draw text box
lda #0
sta BOX_X1H
lda #53
sta BOX_X1L
lda #24
sta BOX_Y1
lda #0
sta BOX_X2H
lda #253
sta BOX_X2L
lda #82
sta BOX_Y2
jsr draw_box
lda #<cottage_text1
sta OUTL
lda #>cottage_text1
sta OUTH
jsr hgr_put_string
jsr hgr_put_string
jsr hgr_put_string
jsr hgr_put_string
rts
;============================
; display cottage text 2
;============================
display_cottage_text2:
;====================
; draw text box
lda #0
sta BOX_X1H
lda #40
sta BOX_X1L
lda #15
sta BOX_Y1
lda #0
sta BOX_X2H
lda #255
sta BOX_X2L
lda #96
sta BOX_Y2
jsr draw_box
lda #<cottage_text2
sta OUTL
lda #>cottage_text2
sta OUTH
jsr hgr_put_string
jsr hgr_put_string
jsr hgr_put_string
jsr hgr_put_string
jsr hgr_put_string
jsr hgr_put_string
jsr hgr_put_string
rts
;============================
; display cottage text 3
;============================
display_cottage_text3:
;====================
; draw text box
lda #0
sta BOX_X1H
lda #30
sta BOX_X1L
lda #20
sta BOX_Y1
lda #0
sta BOX_X2H
lda #253
sta BOX_X2L
lda #86
sta BOX_Y2
jsr draw_box
lda #<cottage_text3
sta OUTL
lda #>cottage_text3
sta OUTH
jsr hgr_put_string
jsr hgr_put_string
jsr hgr_put_string
jsr hgr_put_string
jsr hgr_put_string
rts
peasant_text:
.byte 25,2,"Peasant's Quest",0
cottage_text1:
.byte 9,35,"YOU are Rather Dashing, a",0
.byte 9,44,"humble peasant living in",0
.byte 9,53,"the peasant kingdom of",0
.byte 9,62,"Peasantry.",0
.byte 0,53,24, 0,253,82
.byte 9,35,"YOU are Rather Dashing, a",13
.byte "humble peasant living in",13
.byte "the peasant kingdom of",13
.byte "Peasantry.",0
; wait a few seconds
cottage_text2:
.byte 8,25,"You return home from a",0
.byte 8,33,"vacation on Scalding Lake",0
.byte 8,41,"only to find that TROGDOR",0
.byte 8,49,"THE BURNINATOR has",0
.byte 8,57,"burninated your thatched",0
.byte 8,65,"roof cottage along with all",0
.byte 8,73,"your goods and services.",0
.byte 0,40,15, 0,255,96
.byte 8,25,"You return home from a",13
.byte "vacation on Scalding Lake",13
.byte "only to find that TROGDOR",13
.byte "THE BURNINATOR has",13
.byte "burninated your thatched",13
.byte "roof cottage along with all",13
.byte "your goods and services.",0
; wait a few seconds, then start walking toward cottage
cottage_text3:
.byte 7,33,"With nothing left to lose,",0
.byte 7,41,"you swear to get revenge on",0
.byte 7,49,"the Wingaling Dragon in the",0
.byte 7,57,"name of burninated peasants",0
.byte 7,65,"everywhere.",0
.byte 0,30,20, 0,253,86
.byte 7,33,"With nothing left to lose,",13
.byte "you swear to get revenge on",13
.byte "the Wingaling Dragon in the",13
.byte "name of burninated peasants",13
.byte "everywhere.",0
; Walk to edge of screen

View File

@ -62,7 +62,14 @@ knight_walk_loop:
check_knight_action1:
cmp #0
bne check_knight_action2
jsr display_river_text1
lda #<river_message1
sta OUTL
lda #>river_message1
sta OUTH
jsr hgr_text_box
jmp done_knight_action
check_knight_action2:
@ -74,7 +81,13 @@ check_knight_action2:
check_knight_action3:
cmp #17
bne done_knight_action
jsr display_knight_text1
lda #<knight_message1
sta OUTL
lda #>knight_message1
sta OUTH
jsr hgr_text_box
done_knight_action:
@ -186,40 +199,10 @@ done_knight:
; stops as approach knight
knight_message1:
.byte 0,35,34, 0,253,72
.byte 7,49,"OK go for it.",0
;============================
; display lake_e text 1
;============================
display_knight_text1:
;====================
; draw text box
lda #0
sta BOX_X1H
lda #35
sta BOX_X1L
lda #34
sta BOX_Y1
lda #0
sta BOX_X2H
lda #253
sta BOX_X2L
lda #72
sta BOX_Y2
jsr draw_box
lda #<knight_message1
sta OUTL
lda #>knight_message1
sta OUTH
jsr hgr_put_string
rts
knight_path:
.byte 0,107

View File

@ -59,7 +59,13 @@ lake_e_walk_loop:
check_lake_e_action1:
cmp #10
bne check_lake_e_action2
jsr display_lake_e_text1
lda #<lake_e_message1
sta OUTL
lda #>lake_e_message1
sta OUTH
jsr hgr_text_box
jmp done_lake_e_action
check_lake_e_action2:
@ -113,42 +119,13 @@ done_lake_e:
; walk sideways, near corner
lake_e_message1:
.byte 0,35,34, 0,253,72
.byte 7,49,"That's a nice looking lake.",0
; nearly hit head on sign, it goes away, walk off screen
;============================
; display lake_e text 1
;============================
display_lake_e_text1:
;====================
; draw text box
lda #0
sta BOX_X1H
lda #35
sta BOX_X1L
lda #34
sta BOX_Y1
lda #0
sta BOX_X2H
lda #253
sta BOX_X2L
lda #72
sta BOX_Y2
jsr draw_box
lda #<lake_e_message1
sta OUTL
lda #>lake_e_message1
sta OUTH
jsr hgr_put_string
rts
lake_e_path:
.byte 7,151

View File

@ -60,7 +60,13 @@ lake_w_walk_loop:
check_lake_w_action1:
cmp #0
bne check_lake_w_action2
jsr display_cottage_text3
; re-display cottage text 3
lda #<cottage_text3
sta OUTL
lda #>cottage_text3
sta OUTH
jsr hgr_text_box
jmp done_lake_w_action
check_lake_w_action2:
@ -116,9 +122,10 @@ done_lake_w:
; walk halfway across the screen
lake_w_message1:
.byte 8,41,"You head east toward the",0
.byte 8,49,"mountain atop which",0
.byte 8,57,"TROGDOR lives.",0
.byte 0,43,24, 0,253,82
.byte 8,41,"You head east toward the",13
.byte "mountain atop which",13
.byte "TROGDOR lives.",0
; walk to edge
@ -128,33 +135,12 @@ lake_w_message1:
;============================
display_lake_w_text1:
;====================
; draw text box
lda #0
sta BOX_X1H
lda #43
sta BOX_X1L
lda #24
sta BOX_Y1
lda #0
sta BOX_X2H
lda #253
sta BOX_X2L
lda #82
sta BOX_Y2
jsr draw_box
lda #<lake_w_message1
sta OUTL
lda #>lake_w_message1
sta OUTH
jsr hgr_put_string
jsr hgr_put_string
jsr hgr_put_string
jsr hgr_text_box
rts

View File

@ -62,7 +62,14 @@ river_walk_loop:
check_river_action1:
cmp #10
bne check_river_action2
jsr display_river_text1
lda #<river_message1
sta OUTL
lda #>river_message1
sta OUTH
jsr hgr_text_box
jmp done_river_action
check_river_action2:
@ -117,45 +124,13 @@ done_river:
; walk up a bit
river_message1:
.byte 7,49,"You can start playing in a",0
.byte 7,57,"second here.",0
.byte 0,35,34, 0,253,82
.byte 7,49,"You can start playing in a",13
.byte "second here.",0
; walks behind tree
;============================
; display river text 1
;============================
display_river_text1:
;====================
; draw text box
lda #0
sta BOX_X1H
lda #35
sta BOX_X1L
lda #34
sta BOX_Y1
lda #0
sta BOX_X2H
lda #253
sta BOX_X2L
lda #82
sta BOX_Y2
jsr draw_box
lda #<river_message1
sta OUTL
lda #>river_message1
sta OUTH
jsr hgr_put_string
jsr hgr_put_string
rts
river_path:
.byte 32,157

View File

@ -25,6 +25,7 @@ FRAME = $65
ALTFIRE = $66
ALTL = $67
ALTH = $68
SAVED_X = $69
; pt3 player registers
AY_REGISTERS = $70