peasant: you can now walk to different locations

This commit is contained in:
Vince Weaver 2021-08-15 21:08:38 -04:00
parent 12beab8608
commit 16b7249b79
8 changed files with 218 additions and 22 deletions

View File

@ -69,7 +69,7 @@ title.o: title.s \
INTRO: intro.o
ld65 -o INTRO intro.o -C $(LINKER_SCRIPTS)/apple2_6000.inc
intro.o: intro.s graphics/graphics.inc sprites/peasant_sprite.inc \
intro.o: intro.s graphics/graphics_intro.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 hgr_text_box.s \

View File

@ -26,7 +26,7 @@ T 3 = VID_LOGO 6911 bytes 27S = 1T11S
T 5 = TITLE 9662 bytes 38S = 2T6S
T 8 = INTRO 14265 bytes 56S = 3T8S
T 12 = COPY_CHECK 4642 bytes 18S = 1T2S
T 14 = PEASANT 15332 bytes 60S = 3T12S ; 88 is max?
238, to 280 (6)

View File

@ -5,20 +5,40 @@ PNG2HGR = ../../../utils/hgr-utils/png2hgr
LZSA = ~/research/lzsa/lzsa/lzsa
B2D = ../../../utils/bmp2dhr/b2d
all: graphics.inc
all: graphics_intro.inc graphics.inc
graphics_intro.inc: \
cottage.lzsa \
lake_e.lzsa \
lake_w.lzsa \
river.lzsa \
knight.lzsa
echo "cottage_lzsa: .incbin \"cottage.lzsa\"" > graphics_intro.inc
echo "lake_w_lzsa: .incbin \"lake_w.lzsa\"" >> graphics_intro.inc
echo "lake_e_lzsa: .incbin \"lake_e.lzsa\"" >> graphics_intro.inc
echo "river_lzsa: .incbin \"river.lzsa\"" >> graphics_intro.inc
echo "knight_lzsa: .incbin \"knight.lzsa\"" >> graphics_intro.inc
echo "waterfall_lzsa: .incbin \"waterfall.lzsa\"" >> graphics_intro.inc
###
graphics.inc: \
cottage.lzsa \
lake_e.lzsa \
lake_w.lzsa \
river.lzsa \
knight.lzsa
knight.lzsa \
waterfall.lzsa \
todo.lzsa
echo "cottage_lzsa: .incbin \"cottage.lzsa\"" > graphics.inc
echo "lake_w_lzsa: .incbin \"lake_w.lzsa\"" >> graphics.inc
echo "lake_e_lzsa: .incbin \"lake_e.lzsa\"" >> graphics.inc
echo "river_lzsa: .incbin \"river.lzsa\"" >> graphics.inc
echo "knight_lzsa: .incbin \"knight.lzsa\"" >> graphics.inc
echo "waterfall_lzsa: .incbin \"waterfall.lzsa\"" >> graphics.inc
echo "todo_lzsa: .incbin \"todo.lzsa\"" >> graphics.inc
###
@ -86,21 +106,19 @@ knight.hgr: knight.png
###
trogdor.lzsa: trogdor.hgr
$(LZSA) -r -f2 trogdor.hgr trogdor.lzsa
waterfall.lzsa: waterfall.hgr
$(LZSA) -r -f2 waterfall.hgr waterfall.lzsa
trogdor.hgr: trogdor.png
$(PNG2HGR) trogdor.png > trogdor.hgr
waterfall.hgr: waterfall.png
$(PNG2HGR) waterfall.png > waterfall.hgr
###
game_over.lzsa: game_over.hgr
$(LZSA) -r -f2 game_over.hgr game_over.lzsa
game_over.hgr: game_over.png
$(PNG2HGR) game_over.png > game_over.hgr
todo.lzsa: todo.hgr
$(LZSA) -r -f2 todo.hgr todo.lzsa
todo.hgr: todo.png
$(PNG2HGR) todo.png > todo.hgr
###

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -129,4 +129,4 @@ escape_handler:
.include "wait_a_bit.s"
.include "graphics/graphics.inc"
.include "graphics/graphics_intro.inc"

View File

@ -24,6 +24,8 @@ peasant_quest:
lda #0
sta FRAME
@ -43,18 +45,40 @@ peasant_quest:
sta PEASANT_XADD
sta PEASANT_YADD
; setup map location
lda #4
sta MAP_X
lda #1
sta MAP_Y
jsr update_map_location
;=============================
;=============================
; new screen location
;=============================
;=============================
new_location:
lda #0
sta GAME_OVER
;=====================
; load bg
lda #<(knight_lzsa)
ldx MAP_LOCATION
lda map_backgrounds_low,X
sta getsrc_smc+1
lda #>(knight_lzsa)
lda map_backgrounds_hi,X
sta getsrc_smc+2
lda #$40
jsr decompress_lzsa2_fast
; put peasant text
lda #<peasant_text
sta OUTL
lda #>peasant_text
@ -121,26 +145,75 @@ game_loop:
bcs peasant_x_toobig ; bge
bcc done_movex
;============================
peasant_x_toobig:
lda #0
sta PEASANT_XADD
lda #39
inc MAP_X
jsr new_map_location
lda #0 ; new X location
jmp done_movex
;============================
peasant_x_negative:
lda #0
sta PEASANT_XADD
dec MAP_X
jsr new_map_location
lda #39 ; new X location
jmp done_movex
; check edge of screen
done_movex:
sta PEASANT_X
; Move Peasant Y
clc
lda PEASANT_Y
adc PEASANT_YADD
cmp #45
bcc peasant_y_negative ; blt
cmp #150
bcs peasant_y_toobig ; bge
bcc done_movey
;============================
peasant_y_toobig:
inc MAP_Y
jsr new_map_location
lda #45 ; new X location
jmp done_movey
;============================
peasant_y_negative:
dec MAP_Y
jsr new_map_location
lda #150 ; new X location
jmp done_movey
; check edge of screen
done_movey:
sta PEASANT_Y
; save behind new position
lda PEASANT_X
@ -165,6 +238,7 @@ peasant_the_same:
jsr check_keyboard
lda GAME_OVER
bmi oops_new_location
bne game_over
@ -176,6 +250,8 @@ peasant_the_same:
jmp game_loop
oops_new_location:
jmp new_location
;************************
@ -306,3 +382,102 @@ clear_bottom:
jsr vgi_simple_rectangle
rts
;=====================
;
;=====================
new_map_location:
lda #$FF
sta GAME_OVER
; fall through
;==================
; update map
; on main map, it's (MAP_Y*5)+MAP_X
update_map_location:
; put in map
map_wrap_x:
; wrap X (0..4)
lda MAP_X
bmi map_x_went_negative
cmp #5
bcc map_wrap_y ; blt
lda #0
beq update_map_x ; bra
map_x_went_negative:
lda #4
update_map_x:
sta MAP_X
map_wrap_y:
; wrap Y (0..3)
lda MAP_Y
and #$3
sta MAP_Y
clc
lda MAP_Y
asl
asl
adc MAP_Y
adc MAP_X
sta MAP_LOCATION
rts
map_backgrounds_low:
.byte <todo_lzsa ; 0
.byte <todo_lzsa ; 1
.byte <todo_lzsa ; 2
.byte <todo_lzsa ; 3
.byte <waterfall_lzsa ; 4 -- waterfall
.byte <todo_lzsa ; 5
.byte <todo_lzsa ; 6
.byte <todo_lzsa ; 7
.byte <river_lzsa ; 8 -- river
.byte <knight_lzsa ; 9 -- knight
.byte <todo_lzsa ; 10
.byte <cottage_lzsa ; 11 -- cottage
.byte <lake_w_lzsa ; 12 -- lake west
.byte <lake_e_lzsa ; 13 -- lake east
.byte <todo_lzsa ; 14
.byte <todo_lzsa ; 15
.byte <todo_lzsa ; 16
.byte <todo_lzsa ; 17
.byte <todo_lzsa ; 18
.byte <todo_lzsa ; 19
map_backgrounds_hi:
.byte >todo_lzsa ; 0
.byte >todo_lzsa ; 1
.byte >todo_lzsa ; 2
.byte >todo_lzsa ; 3
.byte >waterfall_lzsa ; 4 -- waterfall
.byte >todo_lzsa ; 5
.byte >todo_lzsa ; 6
.byte >todo_lzsa ; 7
.byte >river_lzsa ; 8 -- river
.byte >knight_lzsa ; 9 -- knight
.byte >todo_lzsa ; 10
.byte >cottage_lzsa ; 11 -- cottage
.byte >lake_w_lzsa ; 12 -- lake west
.byte >lake_e_lzsa ; 13 -- lake east
.byte >todo_lzsa ; 14
.byte >todo_lzsa ; 15
.byte >todo_lzsa ; 16
.byte >todo_lzsa ; 17
.byte >todo_lzsa ; 18
.byte >todo_lzsa ; 19

View File

@ -29,6 +29,9 @@ SAVED_X = $69
PEASANT_XADD = $6A
PEASANT_YADD = $6B
GAME_OVER = $6C
MAP_X = $6D
MAP_Y = $6E
MAP_LOCATION = $6F
; pt3 player registers
AY_REGISTERS = $70