2021-08-15 00:23:41 -04:00
|
|
|
; A Peasant's Quest????
|
|
|
|
|
|
|
|
; by Vince `deater` Weaver vince@deater.net
|
|
|
|
|
|
|
|
; with apologies to everyone
|
|
|
|
|
|
|
|
.include "hardware.inc"
|
|
|
|
.include "zp.inc"
|
|
|
|
|
|
|
|
.include "qload.inc"
|
|
|
|
|
|
|
|
|
2021-08-15 01:12:43 -04:00
|
|
|
ENDING_COPY = 1
|
|
|
|
|
2021-08-15 00:23:41 -04:00
|
|
|
|
|
|
|
peasant_quest:
|
2021-08-15 01:12:43 -04:00
|
|
|
lda #0
|
|
|
|
sta GAME_OVER
|
2021-08-15 00:23:41 -04:00
|
|
|
|
|
|
|
jsr hgr_make_tables
|
|
|
|
|
|
|
|
jsr HGR2 ; Hi-res graphics, no text at bottom
|
|
|
|
; Y=0, A=0 after this called
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
sta FRAME
|
|
|
|
|
|
|
|
;=========================
|
|
|
|
; init peasant position
|
|
|
|
; draw at 18,107
|
|
|
|
|
|
|
|
lda #18
|
|
|
|
sta PEASANT_X
|
|
|
|
lda #107
|
|
|
|
sta PEASANT_Y
|
|
|
|
|
|
|
|
lda #PEASANT_DIR_RIGHT
|
|
|
|
sta PEASANT_DIR
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
sta PEASANT_XADD
|
|
|
|
sta PEASANT_YADD
|
|
|
|
|
|
|
|
;=====================
|
|
|
|
; load bg
|
|
|
|
|
|
|
|
lda #<(knight_lzsa)
|
|
|
|
sta getsrc_smc+1
|
|
|
|
lda #>(knight_lzsa)
|
|
|
|
sta getsrc_smc+2
|
|
|
|
|
|
|
|
lda #$40
|
|
|
|
|
|
|
|
jsr decompress_lzsa2_fast
|
|
|
|
|
|
|
|
lda #<peasant_text
|
|
|
|
sta OUTL
|
|
|
|
lda #>peasant_text
|
|
|
|
sta OUTH
|
|
|
|
|
|
|
|
jsr hgr_put_string
|
|
|
|
|
|
|
|
; put score
|
|
|
|
|
|
|
|
lda #<score_text
|
|
|
|
sta OUTL
|
|
|
|
lda #>score_text
|
|
|
|
sta OUTH
|
|
|
|
|
|
|
|
jsr hgr_put_string
|
|
|
|
|
|
|
|
|
|
|
|
; draw rectangle on bottom
|
|
|
|
|
2021-08-15 01:12:43 -04:00
|
|
|
jsr clear_bottom
|
2021-08-15 00:23:41 -04:00
|
|
|
|
|
|
|
jsr hgr_save
|
|
|
|
|
|
|
|
;====================
|
|
|
|
; save background
|
|
|
|
|
|
|
|
lda PEASANT_X
|
|
|
|
sta CURSOR_X
|
|
|
|
lda PEASANT_Y
|
|
|
|
sta CURSOR_Y
|
|
|
|
|
|
|
|
;=======================
|
|
|
|
; draw initial peasant
|
|
|
|
|
|
|
|
jsr save_bg_7x30
|
2021-08-15 01:19:26 -04:00
|
|
|
|
2021-08-15 00:23:41 -04:00
|
|
|
jsr draw_peasant
|
|
|
|
|
|
|
|
game_loop:
|
|
|
|
|
|
|
|
; redraw peasant if moved
|
|
|
|
|
|
|
|
lda PEASANT_XADD
|
|
|
|
ora PEASANT_YADD
|
|
|
|
beq peasant_the_same
|
|
|
|
|
|
|
|
; restore bg behind peasant
|
|
|
|
|
2021-08-15 01:19:26 -04:00
|
|
|
lda PEASANT_X
|
|
|
|
sta CURSOR_X
|
|
|
|
|
|
|
|
lda PEASANT_Y
|
|
|
|
sta CURSOR_Y
|
|
|
|
|
2021-08-15 00:23:41 -04:00
|
|
|
jsr restore_bg_7x30
|
|
|
|
|
|
|
|
; move peasant
|
|
|
|
|
|
|
|
clc
|
|
|
|
lda PEASANT_X
|
|
|
|
adc PEASANT_XADD
|
|
|
|
bmi peasant_x_negative
|
|
|
|
cmp #40
|
|
|
|
bcs peasant_x_toobig ; bge
|
|
|
|
bcc done_movex
|
|
|
|
|
|
|
|
peasant_x_toobig:
|
|
|
|
lda #0
|
|
|
|
sta PEASANT_XADD
|
|
|
|
lda #39
|
|
|
|
jmp done_movex
|
|
|
|
|
|
|
|
peasant_x_negative:
|
|
|
|
lda #0
|
|
|
|
sta PEASANT_XADD
|
|
|
|
jmp done_movex
|
|
|
|
|
|
|
|
; check edge of screen
|
|
|
|
done_movex:
|
|
|
|
sta PEASANT_X
|
|
|
|
|
|
|
|
clc
|
|
|
|
lda PEASANT_Y
|
|
|
|
adc PEASANT_YADD
|
|
|
|
sta PEASANT_Y
|
|
|
|
|
|
|
|
; save behind new position
|
|
|
|
|
2021-08-15 01:19:26 -04:00
|
|
|
lda PEASANT_X
|
|
|
|
sta CURSOR_X
|
|
|
|
|
|
|
|
lda PEASANT_Y
|
|
|
|
sta CURSOR_Y
|
|
|
|
|
2021-08-15 00:23:41 -04:00
|
|
|
jsr save_bg_7x30
|
|
|
|
|
|
|
|
; draw peasant
|
|
|
|
|
|
|
|
jsr draw_peasant
|
|
|
|
|
|
|
|
peasant_the_same:
|
|
|
|
|
|
|
|
; lda #3
|
|
|
|
; jsr wait_a_bit
|
|
|
|
|
|
|
|
inc FRAME
|
|
|
|
|
|
|
|
jsr check_keyboard
|
|
|
|
|
2021-08-15 01:12:43 -04:00
|
|
|
lda GAME_OVER
|
|
|
|
bne game_over
|
|
|
|
|
2021-08-15 01:19:26 -04:00
|
|
|
|
|
|
|
; delay
|
|
|
|
|
|
|
|
lda #200
|
|
|
|
jsr WAIT
|
|
|
|
|
|
|
|
|
2021-08-15 00:23:41 -04:00
|
|
|
jmp game_loop
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-08-15 01:12:43 -04:00
|
|
|
;************************
|
|
|
|
; copy protection check
|
|
|
|
;************************
|
|
|
|
game_over:
|
|
|
|
exit_copy_check:
|
|
|
|
lda #LOAD_COPY_CHECK
|
|
|
|
sta WHICH_LOAD
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
2021-08-15 00:23:41 -04:00
|
|
|
|
|
|
|
check_keyboard:
|
|
|
|
|
|
|
|
lda KEYPRESS
|
|
|
|
bmi key_was_pressed
|
|
|
|
rts
|
|
|
|
|
|
|
|
key_was_pressed:
|
|
|
|
|
|
|
|
and #$7f ; strip off high bit
|
|
|
|
|
|
|
|
check_left:
|
2021-08-15 01:19:26 -04:00
|
|
|
cmp #$8
|
|
|
|
beq left_pressed
|
2021-08-15 00:23:41 -04:00
|
|
|
cmp #'A'
|
|
|
|
bne check_right
|
2021-08-15 01:19:26 -04:00
|
|
|
left_pressed:
|
2021-08-15 00:23:41 -04:00
|
|
|
lda #$FF ; move left
|
|
|
|
sta PEASANT_XADD
|
|
|
|
jmp done_check_keyboard
|
|
|
|
|
|
|
|
check_right:
|
2021-08-15 01:19:26 -04:00
|
|
|
cmp #$15
|
|
|
|
beq right_pressed
|
2021-08-15 00:23:41 -04:00
|
|
|
cmp #'D'
|
|
|
|
bne check_up
|
2021-08-15 01:19:26 -04:00
|
|
|
right_pressed:
|
2021-08-15 00:23:41 -04:00
|
|
|
lda #$1
|
|
|
|
sta PEASANT_XADD
|
|
|
|
jmp done_check_keyboard
|
|
|
|
|
|
|
|
check_up:
|
|
|
|
cmp #'W'
|
|
|
|
bne check_down
|
|
|
|
|
2021-08-15 01:12:43 -04:00
|
|
|
lda #$FF
|
2021-08-15 00:23:41 -04:00
|
|
|
sta PEASANT_YADD
|
|
|
|
jmp done_check_keyboard
|
|
|
|
|
|
|
|
check_down:
|
|
|
|
cmp #'S'
|
|
|
|
bne check_enter
|
|
|
|
|
2021-08-15 01:12:43 -04:00
|
|
|
lda #$1
|
2021-08-15 00:23:41 -04:00
|
|
|
sta PEASANT_YADD
|
|
|
|
jmp done_check_keyboard
|
|
|
|
|
|
|
|
check_enter:
|
|
|
|
cmp #13
|
|
|
|
beq enter_pressed
|
|
|
|
cmp #' '
|
|
|
|
bne done_check_keyboard
|
|
|
|
enter_pressed:
|
2021-08-15 01:12:43 -04:00
|
|
|
jsr clear_bottom
|
|
|
|
jsr hgr_input
|
2021-08-15 00:23:41 -04:00
|
|
|
|
2021-08-15 01:12:43 -04:00
|
|
|
jsr parse_input
|
|
|
|
|
|
|
|
jsr clear_bottom
|
2021-08-15 00:23:41 -04:00
|
|
|
|
|
|
|
done_check_keyboard:
|
|
|
|
|
|
|
|
bit KEYRESET
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-08-15 01:12:43 -04:00
|
|
|
peasant_text:
|
|
|
|
.byte 25,2,"Peasant's Quest",0
|
2021-08-15 00:23:41 -04:00
|
|
|
|
2021-08-15 01:12:43 -04:00
|
|
|
score_text:
|
|
|
|
.byte 0,2,"Score: 0 of 150",0
|
2021-08-15 00:23:41 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-08-15 01:12:43 -04:00
|
|
|
parse_input:
|
|
|
|
jsr hgr_save
|
2021-08-15 00:23:41 -04:00
|
|
|
|
2021-08-15 01:12:43 -04:00
|
|
|
lda input_buffer ; get first char FIXME
|
|
|
|
and #$DF ; make uppercase 0110 0001 -> 0100 0001
|
2021-08-15 00:23:41 -04:00
|
|
|
|
2021-08-15 01:12:43 -04:00
|
|
|
parse_copy:
|
|
|
|
cmp #'C'
|
|
|
|
bne parse_version
|
2021-08-15 00:23:41 -04:00
|
|
|
|
2021-08-15 01:12:43 -04:00
|
|
|
; want copy
|
|
|
|
lda #ENDING_COPY
|
|
|
|
sta GAME_OVER
|
|
|
|
jmp done_parse_message
|
|
|
|
|
|
|
|
|
|
|
|
parse_version:
|
|
|
|
cmp #'V'
|
|
|
|
bne parse_help
|
|
|
|
|
|
|
|
lda #<version_message
|
|
|
|
sta OUTL
|
|
|
|
lda #>version_message
|
|
|
|
jmp finish_parse_message
|
|
|
|
|
|
|
|
parse_help:
|
|
|
|
lda #<help_message
|
|
|
|
sta OUTL
|
|
|
|
lda #>help_message
|
|
|
|
|
|
|
|
finish_parse_message:
|
|
|
|
sta OUTH
|
|
|
|
jsr hgr_text_box
|
|
|
|
|
|
|
|
jsr wait_until_keypress
|
|
|
|
|
|
|
|
done_parse_message:
|
|
|
|
jsr hgr_restore
|
2021-08-15 00:23:41 -04:00
|
|
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
2021-08-15 01:12:43 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
2021-08-15 00:23:41 -04:00
|
|
|
.include "decompress_fast_v2.s"
|
|
|
|
.include "wait_keypress.s"
|
|
|
|
|
|
|
|
.include "draw_peasant.s"
|
|
|
|
|
|
|
|
.include "hgr_font.s"
|
|
|
|
.include "draw_box.s"
|
|
|
|
.include "hgr_rectangle.s"
|
|
|
|
.include "hgr_7x30_sprite.s"
|
|
|
|
.include "hgr_1x5_sprite.s"
|
|
|
|
.include "hgr_save_restore.s"
|
|
|
|
.include "hgr_input.s"
|
|
|
|
.include "hgr_tables.s"
|
|
|
|
.include "hgr_text_box.s"
|
|
|
|
|
|
|
|
.include "wait_a_bit.s"
|
|
|
|
|
|
|
|
.include "graphics/graphics.inc"
|
|
|
|
|
|
|
|
|
|
|
|
help_message:
|
|
|
|
.byte 0,43,24, 0,253,82
|
|
|
|
.byte 8,41,"I don't understand. Type",13
|
|
|
|
.byte "HELP for assistances.",0
|
2021-08-15 01:12:43 -04:00
|
|
|
|
|
|
|
version_message:
|
|
|
|
.byte 0,43,24, 0,253,82
|
|
|
|
.byte 8,41,"APPLE ][ PEASANT'S QUEST",13
|
|
|
|
.byte "version 0.2",0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
clear_bottom:
|
|
|
|
; draw rectangle
|
|
|
|
|
|
|
|
lda #$00 ; color is black1
|
|
|
|
sta VGI_RCOLOR
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
sta VGI_RX1
|
|
|
|
lda #183
|
|
|
|
sta VGI_RY1
|
|
|
|
lda #140
|
|
|
|
sta VGI_RXRUN
|
|
|
|
lda #9
|
|
|
|
sta VGI_RYRUN
|
|
|
|
|
|
|
|
jsr vgi_simple_rectangle
|
|
|
|
|
|
|
|
lda #140
|
|
|
|
sta VGI_RX1
|
|
|
|
lda #183
|
|
|
|
sta VGI_RY1
|
|
|
|
lda #140
|
|
|
|
sta VGI_RXRUN
|
|
|
|
lda #9
|
|
|
|
sta VGI_RYRUN
|
|
|
|
|
|
|
|
jsr vgi_simple_rectangle
|
|
|
|
|
|
|
|
rts
|