mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-06-16 22:29:29 +00:00
keen: move to 128x80 tilemap
more difficult than 256x40, but all levels should fit
This commit is contained in:
parent
1b549d860c
commit
eb68006055
|
@ -52,9 +52,10 @@ MARS: mars.o
|
||||||
|
|
||||||
mars.o: mars.s zp.inc hardware.inc game_over.s \
|
mars.o: mars.s zp.inc hardware.inc game_over.s \
|
||||||
gr_fade.s \
|
gr_fade.s \
|
||||||
|
mars_keyboard.s draw_tilemap.s \
|
||||||
mars_sfx.s longer_sound.s \
|
mars_sfx.s longer_sound.s \
|
||||||
text_help.s \
|
text_help.s \
|
||||||
maps/mars_map.gr.zx02 graphics/parts.gr.zx02
|
maps/mars_new.zx02 graphics/parts.gr.zx02
|
||||||
ca65 -o mars.o mars.s -l mars.lst
|
ca65 -o mars.o mars.s -l mars.lst
|
||||||
|
|
||||||
####
|
####
|
||||||
|
|
|
@ -108,8 +108,9 @@ done_move_to_line:
|
||||||
; local tilemap subset is 20x12 tiles = 240 bytes
|
; local tilemap subset is 20x12 tiles = 240 bytes
|
||||||
; nicely fits in one page
|
; nicely fits in one page
|
||||||
;
|
;
|
||||||
; big tilemap is 256*40
|
|
||||||
; so each row is a page
|
; big tilemap is 128x80
|
||||||
|
; sad, was much cleaner to implement when 256x40
|
||||||
|
|
||||||
; TILEMAP_X, TILEMAP_Y specify where in big
|
; TILEMAP_X, TILEMAP_Y specify where in big
|
||||||
|
|
||||||
|
@ -118,19 +119,33 @@ TILEMAP_Y_COPY_SIZE = 12
|
||||||
|
|
||||||
copy_tilemap_subset:
|
copy_tilemap_subset:
|
||||||
|
|
||||||
|
; TODO: lookup table?
|
||||||
|
; would be sorta big
|
||||||
|
|
||||||
|
|
||||||
|
lda #0
|
||||||
|
sta tilemap_count_smc+1
|
||||||
|
|
||||||
; set start
|
; set start
|
||||||
lda TILEMAP_Y
|
lda TILEMAP_Y
|
||||||
|
lsr
|
||||||
|
|
||||||
|
; set odd/even
|
||||||
|
ldx #0
|
||||||
|
bcc skip_odd_row
|
||||||
|
ldx #$80
|
||||||
|
skip_odd_row:
|
||||||
|
stx cptl1_smc+1
|
||||||
|
|
||||||
clc ; set start
|
clc ; set start
|
||||||
adc #>big_tilemap ; each row is a page, so adding
|
adc #>big_tilemap ; each even row is a page, so adding
|
||||||
; Y to top byte is indexing to row
|
; Y to top byte is indexing to row
|
||||||
|
|
||||||
sta cptl1_smc+2 ; set proper row in big tilemap
|
sta cptl1_smc+2 ; set proper row in big tilemap
|
||||||
adc #TILEMAP_Y_COPY_SIZE
|
|
||||||
sta cptl3_smc+1 ; set loop limit (end)
|
|
||||||
|
|
||||||
; reset row
|
|
||||||
lda #<tilemap
|
lda #<tilemap
|
||||||
sta cptl2_smc+1 ; set small tilemap to row0
|
sta cptl2_smc+1 ; reset small tilemap to row0
|
||||||
|
|
||||||
cp_tilemap_outer_loop:
|
cp_tilemap_outer_loop:
|
||||||
|
|
||||||
|
@ -138,6 +153,8 @@ cp_tilemap_outer_loop:
|
||||||
ldy #0
|
ldy #0
|
||||||
cp_tilemap_inner_loop:
|
cp_tilemap_inner_loop:
|
||||||
|
|
||||||
|
; TODO: optimize, totally unroll?
|
||||||
|
|
||||||
cptl1_smc:
|
cptl1_smc:
|
||||||
lda $9400,X
|
lda $9400,X
|
||||||
cptl2_smc:
|
cptl2_smc:
|
||||||
|
@ -148,14 +165,23 @@ cptl2_smc:
|
||||||
bne cp_tilemap_inner_loop
|
bne cp_tilemap_inner_loop
|
||||||
|
|
||||||
; next line
|
; next line
|
||||||
inc cptl1_smc+2 ; incremement page
|
clc
|
||||||
|
lda cptl1_smc+1
|
||||||
|
adc #$80
|
||||||
|
sta cptl1_smc+1
|
||||||
|
|
||||||
|
lda #$0
|
||||||
|
adc cptl1_smc+2
|
||||||
|
sta cptl1_smc+2
|
||||||
|
|
||||||
clc
|
clc
|
||||||
lda cptl2_smc+1 ; increment row
|
lda cptl2_smc+1 ; increment row
|
||||||
adc #TILEMAP_X_COPY_SIZE
|
adc #TILEMAP_X_COPY_SIZE
|
||||||
sta cptl2_smc+1
|
sta cptl2_smc+1
|
||||||
|
|
||||||
lda cptl1_smc+2
|
inc tilemap_count_smc+1
|
||||||
cptl3_smc:
|
tilemap_count_smc:
|
||||||
|
lda #0
|
||||||
cmp #TILEMAP_Y_COPY_SIZE
|
cmp #TILEMAP_Y_COPY_SIZE
|
||||||
bne cp_tilemap_outer_loop
|
bne cp_tilemap_outer_loop
|
||||||
|
|
||||||
|
@ -163,7 +189,8 @@ done_tilemap_subset:
|
||||||
|
|
||||||
; activate yorps
|
; activate yorps
|
||||||
|
|
||||||
ldx #0
|
ldx NUM_ENEMIES
|
||||||
|
beq done_yorps
|
||||||
|
|
||||||
clc
|
clc
|
||||||
lda TILEMAP_X
|
lda TILEMAP_X
|
||||||
|
@ -181,8 +208,8 @@ activate_yorp_loop:
|
||||||
sta enemy_data_out,X
|
sta enemy_data_out,X
|
||||||
|
|
||||||
next_yorp:
|
next_yorp:
|
||||||
inx
|
dex
|
||||||
cpx #NUM_ENEMIES
|
bpl activate_yorp_loop
|
||||||
bne activate_yorp_loop
|
|
||||||
|
|
||||||
|
done_yorps:
|
||||||
rts
|
rts
|
||||||
|
|
|
@ -62,7 +62,6 @@ keen_start:
|
||||||
|
|
||||||
lda #0 ; offset from tile location
|
lda #0 ; offset from tile location
|
||||||
sta KEEN_X
|
sta KEEN_X
|
||||||
lda #0
|
|
||||||
sta KEEN_Y
|
sta KEEN_Y
|
||||||
|
|
||||||
lda #RIGHT ; direction
|
lda #RIGHT ; direction
|
||||||
|
@ -72,14 +71,14 @@ keen_start:
|
||||||
; load level1 background
|
; load level1 background
|
||||||
;====================================
|
;====================================
|
||||||
|
|
||||||
lda #<level1_bg_zx02
|
; lda #<level1_bg_zx02
|
||||||
sta ZX0_src
|
; sta ZX0_src
|
||||||
lda #>level1_bg_zx02
|
; lda #>level1_bg_zx02
|
||||||
sta ZX0_src+1
|
; sta ZX0_src+1
|
||||||
|
|
||||||
lda #$c ; load to page $c00
|
; lda #$c ; load to page $c00
|
||||||
|
|
||||||
jsr full_decomp
|
; jsr full_decomp
|
||||||
|
|
||||||
|
|
||||||
;====================================
|
;====================================
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
; Keen MARS main map
|
; Keen MARS main map
|
||||||
|
;
|
||||||
; TODO: should make it scrollable, etc / tilemap
|
|
||||||
; TODO: fade in effect (from mode7 demo)
|
|
||||||
|
|
||||||
; by deater (Vince Weaver) <vince@deater.net>
|
; by deater (Vince Weaver) <vince@deater.net>
|
||||||
|
|
||||||
; Zero Page
|
; Zero Page
|
||||||
|
@ -10,6 +7,11 @@
|
||||||
.include "hardware.inc"
|
.include "hardware.inc"
|
||||||
.include "common_defines.inc"
|
.include "common_defines.inc"
|
||||||
|
|
||||||
|
|
||||||
|
; or are there?
|
||||||
|
NUM_ENEMIES = 0
|
||||||
|
TILE_COLS = 20 ; define this elsewhere?
|
||||||
|
|
||||||
mars_start:
|
mars_start:
|
||||||
;===================
|
;===================
|
||||||
; init screen
|
; init screen
|
||||||
|
@ -25,7 +27,11 @@ mars_start:
|
||||||
jsr clear_all ; avoid grey stripes at load
|
jsr clear_all ; avoid grey stripes at load
|
||||||
|
|
||||||
lda KEENS
|
lda KEENS
|
||||||
bmi return_to_title
|
bpl plenty_of_keens
|
||||||
|
|
||||||
|
jmp return_to_title
|
||||||
|
|
||||||
|
plenty_of_keens:
|
||||||
|
|
||||||
;=====================
|
;=====================
|
||||||
; init vars
|
; init vars
|
||||||
|
@ -59,20 +65,46 @@ mars_start:
|
||||||
cmp #GAME_OVER
|
cmp #GAME_OVER
|
||||||
beq return_to_title
|
beq return_to_title
|
||||||
|
|
||||||
|
|
||||||
|
; TODO: get this from MARS_X and MARS_Y
|
||||||
|
|
||||||
|
lda #1
|
||||||
|
sta KEEN_TILEX
|
||||||
|
lda #13
|
||||||
|
sta KEEN_TILEY
|
||||||
|
|
||||||
|
lda #0
|
||||||
|
sta KEEN_X
|
||||||
|
sta KEEN_Y
|
||||||
|
|
||||||
;====================================
|
;====================================
|
||||||
; load mars background
|
; load mars tilemap
|
||||||
;====================================
|
;====================================
|
||||||
|
|
||||||
lda #<mars_zx02
|
lda #<mars_data_zx02
|
||||||
sta ZX0_src
|
sta ZX0_src
|
||||||
lda #>mars_zx02
|
lda #>mars_data_zx02
|
||||||
sta ZX0_src+1
|
sta ZX0_src+1
|
||||||
|
lda #$90 ; load to page $9000
|
||||||
lda #$c ; load to page $c00
|
|
||||||
|
|
||||||
jsr full_decomp
|
jsr full_decomp
|
||||||
|
|
||||||
|
|
||||||
|
;====================================
|
||||||
|
; copy in tilemap subset
|
||||||
|
;====================================
|
||||||
|
; FIXME: start values
|
||||||
|
; center around KEEN_X, KEEN_Y
|
||||||
|
|
||||||
|
lda #0
|
||||||
|
sta TILEMAP_X
|
||||||
|
lda #5
|
||||||
|
sta TILEMAP_Y
|
||||||
|
|
||||||
|
jsr copy_tilemap_subset
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
lda #1
|
lda #1
|
||||||
sta INITIAL_SOUND
|
sta INITIAL_SOUND
|
||||||
|
|
||||||
|
@ -87,11 +119,10 @@ mars_start:
|
||||||
;====================================
|
;====================================
|
||||||
;====================================
|
;====================================
|
||||||
|
|
||||||
keen_loop:
|
mars_loop:
|
||||||
|
; draw tilemap
|
||||||
|
|
||||||
; copy over background
|
jsr draw_tilemap
|
||||||
|
|
||||||
jsr gr_copy_to_current
|
|
||||||
|
|
||||||
; draw keen
|
; draw keen
|
||||||
|
|
||||||
|
@ -129,7 +160,7 @@ no_frame_oflo:
|
||||||
bne done_with_keen
|
bne done_with_keen
|
||||||
|
|
||||||
|
|
||||||
do_keen_loop:
|
do_mars_loop:
|
||||||
|
|
||||||
;=====================
|
;=====================
|
||||||
; sound effect
|
; sound effect
|
||||||
|
@ -148,7 +179,7 @@ skip_initial_sound:
|
||||||
; lda #200
|
; lda #200
|
||||||
; jsr WAIT
|
; jsr WAIT
|
||||||
|
|
||||||
jmp keen_loop
|
jmp mars_loop
|
||||||
|
|
||||||
|
|
||||||
done_with_keen:
|
done_with_keen:
|
||||||
|
@ -189,38 +220,6 @@ return_to_title:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;==========================
|
|
||||||
; includes
|
|
||||||
;==========================
|
|
||||||
|
|
||||||
; level graphics
|
|
||||||
|
|
||||||
mars_zx02:
|
|
||||||
.incbin "maps/mars_map.gr.zx02"
|
|
||||||
parts_zx02:
|
|
||||||
.incbin "graphics/parts.gr.zx02"
|
|
||||||
|
|
||||||
.include "text_print.s"
|
|
||||||
.include "gr_offsets.s"
|
|
||||||
.include "gr_fast_clear.s"
|
|
||||||
.include "gr_copy.s"
|
|
||||||
.include "gr_pageflip.s"
|
|
||||||
; .include "gr_putsprite_crop.s"
|
|
||||||
.include "zx02_optim.s"
|
|
||||||
.include "gr_fade.s"
|
|
||||||
|
|
||||||
.include "joystick.s"
|
|
||||||
|
|
||||||
.include "text_drawbox.s"
|
|
||||||
.include "text_help.s"
|
|
||||||
.include "text_quit_yn.s"
|
|
||||||
.include "game_over.s"
|
|
||||||
|
|
||||||
|
|
||||||
.include "mars_sfx.s"
|
|
||||||
.include "longer_sound.s"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;=========================
|
;=========================
|
||||||
; draw keen
|
; draw keen
|
||||||
|
@ -312,212 +311,11 @@ draw_keen_even:
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
;=================================
|
||||||
|
;=================================
|
||||||
;==============================
|
; check valid feet
|
||||||
; Handle Keypress
|
;=================================
|
||||||
;==============================
|
;=================================
|
||||||
handle_keypress:
|
|
||||||
|
|
||||||
; first handle joystick
|
|
||||||
lda JOYSTICK_ENABLED
|
|
||||||
beq actually_handle_keypress
|
|
||||||
|
|
||||||
; only check joystick every-other frame
|
|
||||||
lda FRAMEL
|
|
||||||
and #$1
|
|
||||||
beq actually_handle_keypress
|
|
||||||
|
|
||||||
check_button:
|
|
||||||
lda PADDLE_BUTTON0
|
|
||||||
bpl button_clear
|
|
||||||
|
|
||||||
lda JS_BUTTON_STATE
|
|
||||||
bne js_check
|
|
||||||
|
|
||||||
lda #1
|
|
||||||
sta JS_BUTTON_STATE
|
|
||||||
lda #' '
|
|
||||||
jmp check_sound
|
|
||||||
|
|
||||||
button_clear:
|
|
||||||
lda #0
|
|
||||||
sta JS_BUTTON_STATE
|
|
||||||
|
|
||||||
js_check:
|
|
||||||
jsr handle_joystick
|
|
||||||
|
|
||||||
js_check_left:
|
|
||||||
lda value0
|
|
||||||
cmp #$20
|
|
||||||
bcs js_check_right ; if less than 32, left
|
|
||||||
lda #'A'
|
|
||||||
bne check_sound
|
|
||||||
|
|
||||||
js_check_right:
|
|
||||||
cmp #$40
|
|
||||||
bcc js_check_up
|
|
||||||
lda #'D'
|
|
||||||
bne check_sound
|
|
||||||
|
|
||||||
js_check_up:
|
|
||||||
lda value1
|
|
||||||
cmp #$20
|
|
||||||
bcs js_check_down
|
|
||||||
lda #'W'
|
|
||||||
|
|
||||||
bne check_sound
|
|
||||||
|
|
||||||
js_check_down:
|
|
||||||
cmp #$40
|
|
||||||
bcc done_joystick
|
|
||||||
lda #'S'
|
|
||||||
bne check_sound
|
|
||||||
|
|
||||||
|
|
||||||
done_joystick:
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
actually_handle_keypress:
|
|
||||||
lda KEYPRESS
|
|
||||||
bmi keypress
|
|
||||||
|
|
||||||
jmp no_keypress
|
|
||||||
|
|
||||||
keypress:
|
|
||||||
and #$7f ; clear high bit
|
|
||||||
cmp #' '
|
|
||||||
beq check_sound ; make sure not to lose space
|
|
||||||
and #$df ; convert uppercase to lower case
|
|
||||||
|
|
||||||
check_sound:
|
|
||||||
cmp #$14 ; control-T
|
|
||||||
bne check_help
|
|
||||||
|
|
||||||
lda SOUND_STATUS
|
|
||||||
eor #SOUND_DISABLED
|
|
||||||
sta SOUND_STATUS
|
|
||||||
jmp done_keypress
|
|
||||||
|
|
||||||
check_help:
|
|
||||||
cmp #'H' ; H (^H is same as left)
|
|
||||||
bne check_joystick
|
|
||||||
|
|
||||||
jsr print_help
|
|
||||||
jmp done_keypress
|
|
||||||
|
|
||||||
; can't be ^J as that's the same as down
|
|
||||||
check_joystick:
|
|
||||||
cmp #'J' ; J
|
|
||||||
bne check_left
|
|
||||||
|
|
||||||
lda JOYSTICK_ENABLED
|
|
||||||
eor #1
|
|
||||||
sta JOYSTICK_ENABLED
|
|
||||||
jmp done_keypress
|
|
||||||
|
|
||||||
check_left:
|
|
||||||
cmp #'A'
|
|
||||||
beq left_pressed
|
|
||||||
cmp #8 ; left key
|
|
||||||
bne check_right
|
|
||||||
|
|
||||||
left_pressed:
|
|
||||||
ldy MARS_X
|
|
||||||
dey
|
|
||||||
ldx MARS_Y
|
|
||||||
jsr check_valid_feet
|
|
||||||
bcc done_left_pressed
|
|
||||||
dec MARS_X
|
|
||||||
done_left_pressed:
|
|
||||||
jmp done_keypress
|
|
||||||
|
|
||||||
check_right:
|
|
||||||
cmp #'D'
|
|
||||||
beq right_pressed
|
|
||||||
cmp #$15 ; right key
|
|
||||||
bne check_up
|
|
||||||
|
|
||||||
right_pressed:
|
|
||||||
ldy MARS_X
|
|
||||||
iny
|
|
||||||
ldx MARS_Y
|
|
||||||
jsr check_valid_feet
|
|
||||||
bcc done_right_pressed
|
|
||||||
inc MARS_X
|
|
||||||
done_right_pressed:
|
|
||||||
jmp done_keypress
|
|
||||||
|
|
||||||
check_up:
|
|
||||||
cmp #'W'
|
|
||||||
beq up_pressed
|
|
||||||
cmp #$0B ; up key
|
|
||||||
bne check_down
|
|
||||||
|
|
||||||
up_pressed:
|
|
||||||
ldy MARS_X
|
|
||||||
ldx MARS_Y
|
|
||||||
dex
|
|
||||||
jsr check_valid_feet
|
|
||||||
bcc done_up_pressed
|
|
||||||
dec MARS_Y
|
|
||||||
done_up_pressed:
|
|
||||||
jmp done_keypress
|
|
||||||
|
|
||||||
check_down:
|
|
||||||
cmp #'S'
|
|
||||||
beq down_pressed
|
|
||||||
cmp #$0A
|
|
||||||
bne check_space
|
|
||||||
down_pressed:
|
|
||||||
ldy MARS_X
|
|
||||||
ldx MARS_Y
|
|
||||||
inx
|
|
||||||
jsr check_valid_feet
|
|
||||||
bcc done_up_pressed
|
|
||||||
inc MARS_Y
|
|
||||||
done_down_pressed:
|
|
||||||
jmp done_keypress
|
|
||||||
|
|
||||||
check_space:
|
|
||||||
cmp #' '
|
|
||||||
bne check_return
|
|
||||||
space_pressed:
|
|
||||||
|
|
||||||
jsr do_action
|
|
||||||
|
|
||||||
jmp done_keypress
|
|
||||||
|
|
||||||
check_return:
|
|
||||||
cmp #13
|
|
||||||
bne check_escape
|
|
||||||
|
|
||||||
return_pressed:
|
|
||||||
;inc LEVEL_OVER
|
|
||||||
|
|
||||||
jsr do_action
|
|
||||||
|
|
||||||
done_return:
|
|
||||||
jmp no_keypress
|
|
||||||
|
|
||||||
check_escape:
|
|
||||||
cmp #27
|
|
||||||
bne done_keypress
|
|
||||||
|
|
||||||
jsr print_quit
|
|
||||||
|
|
||||||
jmp done_keypress
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
done_keypress:
|
|
||||||
no_keypress:
|
|
||||||
bit KEYRESET
|
|
||||||
rts
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; essentially if SCRN(Y,X+2)=9
|
; essentially if SCRN(Y,X+2)=9
|
||||||
check_valid_feet:
|
check_valid_feet:
|
||||||
txa
|
txa
|
||||||
|
@ -554,16 +352,20 @@ feet_valid:
|
||||||
sec
|
sec
|
||||||
rts
|
rts
|
||||||
feet_invalid:
|
feet_invalid:
|
||||||
clc
|
; clc
|
||||||
|
sec
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;====================================
|
||||||
;====================================
|
;====================================
|
||||||
; show parts screen
|
; show parts screen
|
||||||
;====================================
|
;====================================
|
||||||
|
;====================================
|
||||||
|
; TODO: color in if found
|
||||||
do_parts:
|
do_parts:
|
||||||
lda #<parts_zx02
|
lda #<parts_zx02
|
||||||
sta ZX0_src
|
sta ZX0_src
|
||||||
|
@ -590,18 +392,23 @@ done_parts:
|
||||||
|
|
||||||
bit FULLGR
|
bit FULLGR
|
||||||
|
|
||||||
lda #<mars_zx02
|
; lda #<mars_zx02
|
||||||
sta ZX0_src
|
; sta ZX0_src
|
||||||
lda #>mars_zx02
|
; lda #>mars_zx02
|
||||||
sta ZX0_src+1
|
; sta ZX0_src+1
|
||||||
|
|
||||||
lda #$c ; load to page $c00
|
; lda #$c ; load to page $c00
|
||||||
|
|
||||||
jsr full_decomp ; tail call
|
; jsr full_decomp ; tail call
|
||||||
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
;====================================
|
||||||
|
;====================================
|
||||||
|
; Mars action
|
||||||
|
;====================================
|
||||||
|
;====================================
|
||||||
|
; if enter pressed on map
|
||||||
do_action:
|
do_action:
|
||||||
|
|
||||||
lda MARS_X
|
lda MARS_X
|
||||||
|
@ -640,3 +447,46 @@ maybe_exit:
|
||||||
star_colors:
|
star_colors:
|
||||||
.byte $05,$07,$07,$0f
|
.byte $05,$07,$07,$0f
|
||||||
.byte $0f,$07,$05,$0a
|
.byte $0f,$07,$05,$0a
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;==========================
|
||||||
|
; includes
|
||||||
|
;==========================
|
||||||
|
|
||||||
|
; level graphics
|
||||||
|
|
||||||
|
mars_zx02:
|
||||||
|
.incbin "maps/mars_map.gr.zx02"
|
||||||
|
parts_zx02:
|
||||||
|
.incbin "graphics/parts.gr.zx02"
|
||||||
|
|
||||||
|
.include "text_print.s"
|
||||||
|
.include "gr_offsets.s"
|
||||||
|
.include "gr_fast_clear.s"
|
||||||
|
.include "gr_copy.s"
|
||||||
|
.include "gr_pageflip.s"
|
||||||
|
; .include "gr_putsprite_crop.s"
|
||||||
|
.include "zx02_optim.s"
|
||||||
|
.include "gr_fade.s"
|
||||||
|
|
||||||
|
.include "joystick.s"
|
||||||
|
|
||||||
|
.include "text_drawbox.s"
|
||||||
|
.include "text_help.s"
|
||||||
|
.include "text_quit_yn.s"
|
||||||
|
.include "game_over.s"
|
||||||
|
.include "mars_keyboard.s"
|
||||||
|
.include "draw_tilemap.s"
|
||||||
|
|
||||||
|
.include "mars_sfx.s"
|
||||||
|
.include "longer_sound.s"
|
||||||
|
|
||||||
|
|
||||||
|
mars_data_zx02:
|
||||||
|
.incbin "maps/mars_new.zx02"
|
||||||
|
|
||||||
|
; dummy
|
||||||
|
enemy_data_out:
|
||||||
|
enemy_data_tilex:
|
||||||
|
|
203
games/keen/mars_keyboard.s
Normal file
203
games/keen/mars_keyboard.s
Normal file
|
@ -0,0 +1,203 @@
|
||||||
|
;==============================
|
||||||
|
; Handle Keypress
|
||||||
|
;==============================
|
||||||
|
handle_keypress:
|
||||||
|
|
||||||
|
; first handle joystick
|
||||||
|
lda JOYSTICK_ENABLED
|
||||||
|
beq actually_handle_keypress
|
||||||
|
|
||||||
|
; only check joystick every-other frame
|
||||||
|
lda FRAMEL
|
||||||
|
and #$1
|
||||||
|
beq actually_handle_keypress
|
||||||
|
|
||||||
|
check_button:
|
||||||
|
lda PADDLE_BUTTON0
|
||||||
|
bpl button_clear
|
||||||
|
|
||||||
|
lda JS_BUTTON_STATE
|
||||||
|
bne js_check
|
||||||
|
|
||||||
|
lda #1
|
||||||
|
sta JS_BUTTON_STATE
|
||||||
|
lda #' '
|
||||||
|
jmp check_sound
|
||||||
|
|
||||||
|
button_clear:
|
||||||
|
lda #0
|
||||||
|
sta JS_BUTTON_STATE
|
||||||
|
|
||||||
|
js_check:
|
||||||
|
jsr handle_joystick
|
||||||
|
|
||||||
|
js_check_left:
|
||||||
|
lda value0
|
||||||
|
cmp #$20
|
||||||
|
bcs js_check_right ; if less than 32, left
|
||||||
|
lda #'A'
|
||||||
|
bne check_sound
|
||||||
|
|
||||||
|
js_check_right:
|
||||||
|
cmp #$40
|
||||||
|
bcc js_check_up
|
||||||
|
lda #'D'
|
||||||
|
bne check_sound
|
||||||
|
|
||||||
|
js_check_up:
|
||||||
|
lda value1
|
||||||
|
cmp #$20
|
||||||
|
bcs js_check_down
|
||||||
|
lda #'W'
|
||||||
|
|
||||||
|
bne check_sound
|
||||||
|
|
||||||
|
js_check_down:
|
||||||
|
cmp #$40
|
||||||
|
bcc done_joystick
|
||||||
|
lda #'S'
|
||||||
|
bne check_sound
|
||||||
|
|
||||||
|
|
||||||
|
done_joystick:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
actually_handle_keypress:
|
||||||
|
lda KEYPRESS
|
||||||
|
bmi keypress
|
||||||
|
|
||||||
|
jmp no_keypress
|
||||||
|
|
||||||
|
keypress:
|
||||||
|
and #$7f ; clear high bit
|
||||||
|
cmp #' '
|
||||||
|
beq check_sound ; make sure not to lose space
|
||||||
|
and #$df ; convert uppercase to lower case
|
||||||
|
|
||||||
|
check_sound:
|
||||||
|
cmp #$14 ; control-T
|
||||||
|
bne check_help
|
||||||
|
|
||||||
|
lda SOUND_STATUS
|
||||||
|
eor #SOUND_DISABLED
|
||||||
|
sta SOUND_STATUS
|
||||||
|
jmp done_keypress
|
||||||
|
|
||||||
|
check_help:
|
||||||
|
cmp #'H' ; H (^H is same as left)
|
||||||
|
bne check_joystick
|
||||||
|
|
||||||
|
jsr print_help
|
||||||
|
jmp done_keypress
|
||||||
|
|
||||||
|
; can't be ^J as that's the same as down
|
||||||
|
check_joystick:
|
||||||
|
cmp #'J' ; J
|
||||||
|
bne check_left
|
||||||
|
|
||||||
|
lda JOYSTICK_ENABLED
|
||||||
|
eor #1
|
||||||
|
sta JOYSTICK_ENABLED
|
||||||
|
jmp done_keypress
|
||||||
|
|
||||||
|
check_left:
|
||||||
|
cmp #'A'
|
||||||
|
beq left_pressed
|
||||||
|
cmp #8 ; left key
|
||||||
|
bne check_right
|
||||||
|
|
||||||
|
left_pressed:
|
||||||
|
ldy MARS_X
|
||||||
|
dey
|
||||||
|
ldx MARS_Y
|
||||||
|
jsr check_valid_feet
|
||||||
|
bcc done_left_pressed
|
||||||
|
dec MARS_X
|
||||||
|
done_left_pressed:
|
||||||
|
jmp done_keypress
|
||||||
|
|
||||||
|
check_right:
|
||||||
|
cmp #'D'
|
||||||
|
beq right_pressed
|
||||||
|
cmp #$15 ; right key
|
||||||
|
bne check_up
|
||||||
|
|
||||||
|
right_pressed:
|
||||||
|
ldy MARS_X
|
||||||
|
iny
|
||||||
|
ldx MARS_Y
|
||||||
|
jsr check_valid_feet
|
||||||
|
bcc done_right_pressed
|
||||||
|
inc MARS_X
|
||||||
|
done_right_pressed:
|
||||||
|
jmp done_keypress
|
||||||
|
|
||||||
|
check_up:
|
||||||
|
cmp #'W'
|
||||||
|
beq up_pressed
|
||||||
|
cmp #$0B ; up key
|
||||||
|
bne check_down
|
||||||
|
|
||||||
|
up_pressed:
|
||||||
|
ldy MARS_X
|
||||||
|
ldx MARS_Y
|
||||||
|
dex
|
||||||
|
jsr check_valid_feet
|
||||||
|
bcc done_up_pressed
|
||||||
|
dec MARS_Y
|
||||||
|
done_up_pressed:
|
||||||
|
jmp done_keypress
|
||||||
|
|
||||||
|
check_down:
|
||||||
|
cmp #'S'
|
||||||
|
beq down_pressed
|
||||||
|
cmp #$0A
|
||||||
|
bne check_space
|
||||||
|
down_pressed:
|
||||||
|
ldy MARS_X
|
||||||
|
ldx MARS_Y
|
||||||
|
inx
|
||||||
|
jsr check_valid_feet
|
||||||
|
bcc done_up_pressed
|
||||||
|
inc MARS_Y
|
||||||
|
done_down_pressed:
|
||||||
|
jmp done_keypress
|
||||||
|
|
||||||
|
check_space:
|
||||||
|
cmp #' '
|
||||||
|
bne check_return
|
||||||
|
space_pressed:
|
||||||
|
|
||||||
|
jsr do_action
|
||||||
|
|
||||||
|
jmp done_keypress
|
||||||
|
|
||||||
|
check_return:
|
||||||
|
cmp #13
|
||||||
|
bne check_escape
|
||||||
|
|
||||||
|
return_pressed:
|
||||||
|
;inc LEVEL_OVER
|
||||||
|
|
||||||
|
jsr do_action
|
||||||
|
|
||||||
|
done_return:
|
||||||
|
jmp no_keypress
|
||||||
|
|
||||||
|
check_escape:
|
||||||
|
cmp #27
|
||||||
|
bne done_keypress
|
||||||
|
|
||||||
|
jsr print_quit
|
||||||
|
|
||||||
|
jmp done_keypress
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
done_keypress:
|
||||||
|
no_keypress:
|
||||||
|
bit KEYRESET
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user