keen: more work on generic engine

This commit is contained in:
Vince Weaver 2024-04-19 01:41:52 -04:00
parent d246207c95
commit 0652503fbc
8 changed files with 389 additions and 288 deletions

View File

@ -11,7 +11,8 @@ EMPTY_DISK = ../../empty_disk/empty.dsk
all: keen1_lores.dsk
keen1_lores.dsk: HELLO LOADER TITLE ENGINE MARS LEVEL1
keen1_lores.dsk: HELLO LOADER TITLE ENGINE MARS \
LEVEL1 LEVEL2 LEVEL3
cp $(EMPTY_DISK) keen1_lores.dsk
$(DOS33) -y keen1_lores.dsk SAVE A HELLO
$(DOS33) -y keen1_lores.dsk BSAVE -a 0x1000 LOADER
@ -19,7 +20,8 @@ keen1_lores.dsk: HELLO LOADER TITLE ENGINE MARS LEVEL1
$(DOS33) -y keen1_lores.dsk BSAVE -a 0x4000 ENGINE
$(DOS33) -y keen1_lores.dsk BSAVE -a 0x4000 MARS
$(DOS33) -y keen1_lores.dsk BSAVE -a 0x6000 LEVEL1
# $(DOS33) -y keen1_lores.dsk BSAVE -a 0x2000 LEVEL2
$(DOS33) -y keen1_lores.dsk BSAVE -a 0x6000 LEVEL2
$(DOS33) -y keen1_lores.dsk BSAVE -a 0x6000 LEVEL3
###
@ -67,6 +69,26 @@ level1.o: level1.s \
maps/level1_map.zx02
ca65 -o level1.o level1.s -l level1.lst
####
LEVEL2: level2.o
ld65 -o LEVEL2 level2.o -C ../../linker_scripts/apple2_6000.inc
level2.o: level2.s \
maps/level2_map.zx02
ca65 -o level2.o level2.s -l level2.lst
####
LEVEL3: level3.o
ld65 -o LEVEL3 level3.o -C ../../linker_scripts/apple2_6000.inc
level3.o: level3.s \
maps/level3_map.zx02
ca65 -o level3.o level3.s -l level3.lst
####
ENGINE: engine.o
@ -85,19 +107,19 @@ engine.o: engine.s zp.inc hardware.inc \
####
LEVEL2: level2.o
ld65 -o LEVEL2 level2.o -C ../../linker_scripts/apple2_2000.inc
level2.o: level2.s zp.inc hardware.inc \
text_help.s gr_fast_clear.s text_quit_yn.s text_drawbox.s \
level1_enemies.s level1_items.s \
graphics/keen_graphics.inc sprites/keen_sprites.inc \
maps/level2_map.zx02 \
status_bar.s draw_keen.s move_keen.s gr_putsprite_crop.s \
draw_tilemap.s tilemap_lookup.s \
level1_sfx.s longer_sound.s level2_data.inc \
keyboard.s handle_laser.s
ca65 -o level2.o level2.s -l level2.lst
#LEVEL2: level2.o
# ld65 -o LEVEL2 level2.o -C ../../linker_scripts/apple2_2000.inc
#
#level2.o: level2.s zp.inc hardware.inc \
# text_help.s gr_fast_clear.s text_quit_yn.s text_drawbox.s \
# level1_enemies.s level1_items.s \
# graphics/keen_graphics.inc sprites/keen_sprites.inc \
# maps/level2_map.zx02 \
# status_bar.s draw_keen.s move_keen.s gr_putsprite_crop.s \
# draw_tilemap.s tilemap_lookup.s \
# level1_sfx.s longer_sound.s level2_data.inc \
# keyboard.s handle_laser.s
# ca65 -o level2.o level2.s -l level2.lst
####

View File

@ -1,287 +1,40 @@
; Keen PoC Level 2 (First Shrine)
; Level 2 (First Shrine)
; by deater (Vince Weaver) <vince@deater.net>
; at $6000
; Zero Page
.include "zp.inc"
.include "hardware.inc"
.include "common_defines.inc"
level2_data:
.byte 20 ;MAX_TILE_X = 116 ; 116 wide
.byte 26 ;MAX_TILE_Y = 16 ; 16 tall
.include "level2_data.inc"
.byte 1 ;START_KEEN_TILEX = 1
.byte 13 ;START_KEEN_TILEY = 13
.byte 0 ;START_TILEMAP_X = 0
.byte 5 ;START_TILEMAP_Y = 5
level2_start:
;===================
; init screen
.byte 0 ;NUM_ENEMIES = 8
bit KEYRESET
.byte 32 ;HARDTOP_TILES = 32 ; start at 32
.byte 40 ;ALLHARD_TILES = 40 ; start at 40
bit SET_GR
bit PAGE1
bit LORES
bit FULLGR
jsr clear_top ; avoid grey stripes at load
.align $100
;=====================
; init vars
;=====================
lda #0
sta ANIMATE_FRAME
sta FRAMEL
sta FRAMEH
sta KEEN_WALKING
sta KEEN_JUMPING
sta LEVEL_OVER
sta LASER_OUT
sta KEEN_XL
sta KEEN_FALLING
sta KEEN_SHOOTING
sta KEYCARDS
sta ORACLE_SPOKEN
; debug
; lda #9
; sta RAYGUNS
lda #4
sta DRAW_PAGE
; set starting location
lda #START_KEEN_TILEX
sta KEEN_TILEX
lda #START_KEEN_TILEY
sta KEEN_TILEY
lda #0 ; offset from tile location
sta KEEN_X
sta KEEN_Y
lda #RIGHT ; direction
sta KEEN_DIRECTION
;====================================
; load level1 tilemap
;====================================
lda #<level1_data_zx02
sta ZX0_src
lda #>level1_data_zx02
sta ZX0_src+1
lda #$90 ; load to page $9000
jsr full_decomp
;====================================
; copy in tilemap subset
;====================================
; we copy in full screen, 40x48 = 20x12 tiles
; we start out assuming position is 0,5
lda #START_TILEMAP_X
sta TILEMAP_X
lda #START_TILEMAP_Y
sta TILEMAP_Y
jsr copy_tilemap_subset
;====================================
;====================================
; Main loop
;====================================
;====================================
keen_loop:
; draw tilemap
jsr draw_tilemap
; draw enemies
jsr draw_enemies
; draw laser
jsr draw_laser
; draw keen
jsr draw_keen
jsr page_flip
jsr handle_keypress
jsr move_keen
jsr move_enemies
jsr move_laser
;========================
; increment frame count
;========================
inc FRAMEL
bne no_frame_oflo
inc FRAMEH
no_frame_oflo:
;===========================
; check end of level
;===========================
lda LEVEL_OVER
bne done_with_keen
;===========================
; delay
;===========================
; lda #200
; jsr WAIT
jmp keen_loop
done_with_keen:
bit KEYRESET ; clear keypress
; three reasons we could get here
; NEXT_LEVEL = finished level by exiting door
; GAME_OVER = hit ESC and said Y to QUIT
; TOUCHED_ENEMY = touched an enemy
lda LEVEL_OVER
cmp #NEXT_LEVEL
beq level1_levelover
cmp #GAME_OVER
beq level1_gameover
; got here, touched enemy
;============================
; end animation
;============================
lda #1
sta PLAY_END_SOUND
inc KEEN_TILEY ; move down
sec
lda KEEN_TILEX
sbc TILEMAP_X
asl
clc
adc KEEN_X
sta XPOS
sec
lda KEEN_TILEY
sbc TILEMAP_Y
asl
asl
clc
adc KEEN_Y
sta YPOS
level_end_animation:
jsr draw_tilemap
ldx #<keen_sprite_squish
lda #>keen_sprite_squish
stx INL
sta INH
jsr put_sprite_crop
jsr page_flip
lda PLAY_END_SOUND
beq skip_end_sound
ldy #SFX_KEENDIESND
jsr play_sfx
dec PLAY_END_SOUND
skip_end_sound:
lda #50
jsr WAIT
dec YPOS
dec YPOS
bpl level_end_animation
dec KEENS
bpl level1_levelover
level1_gameover:
; mars plays the sound
lda #GAME_OVER
sta LEVEL_OVER
level1_levelover:
lda #LOAD_MARS
sta WHICH_LOAD
rts ; exit back
;==========================
; includes
;==========================
.include "text_print.s"
.include "gr_offsets.s"
.include "gr_fast_clear.s"
.include "gr_pageflip.s"
.include "gr_putsprite_crop.s"
.include "zx02_optim.s"
.include "status_bar.s"
.include "keyboard.s"
.include "joystick.s"
.include "text_drawbox.s"
.include "text_help.s"
.include "text_quit_yn.s"
.include "draw_keen.s"
.include "sprites/keen_sprites.inc"
.include "move_keen.s"
.include "handle_laser.s"
.include "draw_tilemap.s"
.include "level1_enemies.s"
.include "level1_items.s"
.include "level1_sfx.s"
.include "longer_sound.s"
.include "random16.s"
.include "tilemap_lookup.s"
level1_data_zx02:
.incbin "maps/level2_map.zx02"
; at $6100
enemy_data:
.byte $0
.align $100
; at $6200
oracle_message:
; 012345678901234567890123456789012345678
.byte 2,21,"YOU HEAR IN YOUR MIND:",0
.byte 2,22,"IT IS TOO BAD THAT YOU CANNOT READ",0
.byte 2,23,"THE STANDARD GALACTIC ALPHABET, HUMAN",0
.align $100
; at $6300
level2_data_zx02:
.incbin "maps/level2_map.zx02"

287
games/keen/level2_orig.s Normal file
View File

@ -0,0 +1,287 @@
; Keen PoC Level 2 (First Shrine)
; by deater (Vince Weaver) <vince@deater.net>
; Zero Page
.include "zp.inc"
.include "hardware.inc"
.include "common_defines.inc"
.include "level2_data.inc"
level2_start:
;===================
; init screen
bit KEYRESET
bit SET_GR
bit PAGE1
bit LORES
bit FULLGR
jsr clear_top ; avoid grey stripes at load
;=====================
; init vars
;=====================
lda #0
sta ANIMATE_FRAME
sta FRAMEL
sta FRAMEH
sta KEEN_WALKING
sta KEEN_JUMPING
sta LEVEL_OVER
sta LASER_OUT
sta KEEN_XL
sta KEEN_FALLING
sta KEEN_SHOOTING
sta KEYCARDS
sta ORACLE_SPOKEN
; debug
; lda #9
; sta RAYGUNS
lda #4
sta DRAW_PAGE
; set starting location
lda #START_KEEN_TILEX
sta KEEN_TILEX
lda #START_KEEN_TILEY
sta KEEN_TILEY
lda #0 ; offset from tile location
sta KEEN_X
sta KEEN_Y
lda #RIGHT ; direction
sta KEEN_DIRECTION
;====================================
; load level1 tilemap
;====================================
lda #<level1_data_zx02
sta ZX0_src
lda #>level1_data_zx02
sta ZX0_src+1
lda #$90 ; load to page $9000
jsr full_decomp
;====================================
; copy in tilemap subset
;====================================
; we copy in full screen, 40x48 = 20x12 tiles
; we start out assuming position is 0,5
lda #START_TILEMAP_X
sta TILEMAP_X
lda #START_TILEMAP_Y
sta TILEMAP_Y
jsr copy_tilemap_subset
;====================================
;====================================
; Main loop
;====================================
;====================================
keen_loop:
; draw tilemap
jsr draw_tilemap
; draw enemies
jsr draw_enemies
; draw laser
jsr draw_laser
; draw keen
jsr draw_keen
jsr page_flip
jsr handle_keypress
jsr move_keen
jsr move_enemies
jsr move_laser
;========================
; increment frame count
;========================
inc FRAMEL
bne no_frame_oflo
inc FRAMEH
no_frame_oflo:
;===========================
; check end of level
;===========================
lda LEVEL_OVER
bne done_with_keen
;===========================
; delay
;===========================
; lda #200
; jsr WAIT
jmp keen_loop
done_with_keen:
bit KEYRESET ; clear keypress
; three reasons we could get here
; NEXT_LEVEL = finished level by exiting door
; GAME_OVER = hit ESC and said Y to QUIT
; TOUCHED_ENEMY = touched an enemy
lda LEVEL_OVER
cmp #NEXT_LEVEL
beq level1_levelover
cmp #GAME_OVER
beq level1_gameover
; got here, touched enemy
;============================
; end animation
;============================
lda #1
sta PLAY_END_SOUND
inc KEEN_TILEY ; move down
sec
lda KEEN_TILEX
sbc TILEMAP_X
asl
clc
adc KEEN_X
sta XPOS
sec
lda KEEN_TILEY
sbc TILEMAP_Y
asl
asl
clc
adc KEEN_Y
sta YPOS
level_end_animation:
jsr draw_tilemap
ldx #<keen_sprite_squish
lda #>keen_sprite_squish
stx INL
sta INH
jsr put_sprite_crop
jsr page_flip
lda PLAY_END_SOUND
beq skip_end_sound
ldy #SFX_KEENDIESND
jsr play_sfx
dec PLAY_END_SOUND
skip_end_sound:
lda #50
jsr WAIT
dec YPOS
dec YPOS
bpl level_end_animation
dec KEENS
bpl level1_levelover
level1_gameover:
; mars plays the sound
lda #GAME_OVER
sta LEVEL_OVER
level1_levelover:
lda #LOAD_MARS
sta WHICH_LOAD
rts ; exit back
;==========================
; includes
;==========================
.include "text_print.s"
.include "gr_offsets.s"
.include "gr_fast_clear.s"
.include "gr_pageflip.s"
.include "gr_putsprite_crop.s"
.include "zx02_optim.s"
.include "status_bar.s"
.include "keyboard.s"
.include "joystick.s"
.include "text_drawbox.s"
.include "text_help.s"
.include "text_quit_yn.s"
.include "draw_keen.s"
.include "sprites/keen_sprites.inc"
.include "move_keen.s"
.include "handle_laser.s"
.include "draw_tilemap.s"
.include "level1_enemies.s"
.include "level1_items.s"
.include "level1_sfx.s"
.include "longer_sound.s"
.include "random16.s"
.include "tilemap_lookup.s"
level1_data_zx02:
.incbin "maps/level2_map.zx02"
oracle_message:
; 012345678901234567890123456789012345678
.byte 2,21,"YOU HEAR IN YOUR MIND:",0
.byte 2,22,"IT IS TOO BAD THAT YOU CANNOT READ",0
.byte 2,23,"THE STANDARD GALACTIC ALPHABET, HUMAN",0

37
games/keen/level3.s Normal file
View File

@ -0,0 +1,37 @@
; Level 3 (Treasury)
; at $6000
level3_data:
.byte 116 ;MAX_TILE_X = 116 ; 116 wide
.byte 16 ;MAX_TILE_Y = 16 ; 16 tall
.byte 1 ;START_KEEN_TILEX = 1
.byte 13 ;START_KEEN_TILEY = 13
.byte 0 ;START_TILEMAP_X = 0
.byte 5 ;START_TILEMAP_Y = 5
.byte 8 ;NUM_ENEMIES = 8
.byte 32 ;HARDTOP_TILES = 32 ; start at 32
.byte 40 ;ALLHARD_TILES = 40 ; start at 40
.align $100
; at $6100
enemy_data:
.byte $0
.align $100
; at $6200
oracle_message:
.byte $0
.align $100
; at $6300
level1_data_zx02:
.incbin "maps/level3_map.zx02"

View File

@ -211,6 +211,8 @@ keen1_filename:
.byte "LEVEL1",0
keen2_filename:
.byte "LEVEL2",0
keen3_filename:
.byte "LEVEL3",0
;===================================================

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -616,7 +616,7 @@ location_size:
location_actions_low:
.byte <(enter_level-1),<(enter_level-1) ; level1, level2
.byte <(dummy_action-1),<(dummy_action-1)
.byte <(enter_level-1),<(dummy_action-1) ; level3, level4
.byte <(dummy_action-1),<(dummy_action-1)
.byte <(dummy_action-1),<(dummy_action-1)
.byte <(dummy_action-1),<(dummy_action-1)
@ -628,7 +628,7 @@ location_actions_low:
location_actions_high:
.byte >(enter_level-1),>(enter_level-1) ; level1, level2
.byte >(dummy_action-1),>(dummy_action-1)
.byte >(enter_level-1),>(dummy_action-1) ; level3, level4
.byte >(dummy_action-1),>(dummy_action-1)
.byte >(dummy_action-1),>(dummy_action-1)
.byte >(dummy_action-1),>(dummy_action-1)