duke: start level1/level2 split

This commit is contained in:
Vince Weaver 2020-12-17 15:11:31 -05:00
parent 7d4895cc4e
commit 63a44430fa
7 changed files with 273 additions and 8 deletions

View File

@ -8,12 +8,14 @@ LZSA = ~/research/lzsa/lzsa/lzsa
all: duke.dsk
duke.dsk: HELLO LOADER DUKE_TITLE DUKE
duke.dsk: HELLO LOADER DUKE_TITLE DUKE_LEVEL1 DUKE_LEVEL2
cp empty.dsk duke.dsk
$(DOS33) -y duke.dsk SAVE A HELLO
$(DOS33) -y duke.dsk BSAVE -a 0x1000 LOADER
$(DOS33) -y duke.dsk BSAVE -a 0x2000 DUKE
$(DOS33) -y duke.dsk BSAVE -a 0x4000 DUKE_TITLE
$(DOS33) -y duke.dsk BSAVE -a 0x2000 DUKE_LEVEL1
$(DOS33) -y duke.dsk BSAVE -a 0x2000 DUKE_LEVEL2
###
@ -38,10 +40,10 @@ duke_title.o: duke_title.s zp.inc hardware.inc
####
DUKE: duke.o
ld65 -o DUKE duke.o -C ../linker_scripts/apple2_2000.inc
DUKE_LEVEL1: duke_level1.o
ld65 -o DUKE_LEVEL1 duke_level1.o -C ../linker_scripts/apple2_2000.inc
duke.o: duke.s zp.inc hardware.inc duke.s \
duke_level1.o: duke_level1.s zp.inc hardware.inc \
print_help.s gr_fast_clear.s quit_yn.s text_drawbox.s level_end.s \
enemies.s actions.s \
graphics/duke_graphics.inc \
@ -50,7 +52,24 @@ duke.o: duke.s zp.inc hardware.inc duke.s \
draw_tilemap.s \
sound_effects.s speaker_tone.s \
keyboard.s handle_laser.s
ca65 -o duke.o duke.s -l duke.lst
ca65 -o duke_level1.o duke_level1.s -l duke_level1.lst
####
DUKE_LEVEL2: duke_level2.o
ld65 -o DUKE_LEVEL2 duke_level2.o -C ../linker_scripts/apple2_2000.inc
duke_level2.o: duke_level2.s zp.inc hardware.inc \
print_help.s gr_fast_clear.s quit_yn.s text_drawbox.s level_end.s \
enemies.s actions.s \
graphics/duke_graphics.inc \
maps/level2_map.lzsa \
status_bar.s draw_duke.s move_duke.s gr_putsprite_crop.s \
draw_tilemap.s \
sound_effects.s speaker_tone.s \
keyboard.s handle_laser.s
ca65 -o duke_level2.o duke_level2.s -l duke_level2.lst
####

View File

@ -1,3 +1,4 @@
LOAD_TITLE = 0
LOAD_DUKE1 = 1
LOAD_DUKE2 = 2

237
duke/duke_level2.s Normal file
View File

@ -0,0 +1,237 @@
; Duke PoC
; by deater (Vince Weaver) <vince@deater.net>
; Zero Page
.include "zp.inc"
.include "hardware.inc"
.include "common_defines.inc"
TILES = $9000
BIG_TILEMAP = $9400
TILEMAP = $BC00
duke_start:
;===================
; init screen
jsr TEXT
jsr HOME
bit KEYRESET
bit SET_GR
bit PAGE0
bit LORES
bit TEXTGR
jsr clear_top ; avoid grey stripes at load
;=====================
; init vars
;=====================
lda #0
sta ANIMATE_FRAME
sta FRAMEL
sta FRAMEH
sta DISP_PAGE
sta JOYSTICK_ENABLED
sta DUKE_WALKING
sta DUKE_JUMPING
sta LEVEL_OVER
sta LASER_OUT
sta DUKE_XL
sta SCORE0
sta SCORE1
sta SCORE2
sta DUKE_FALLING
sta DUKE_SHOOTING
sta KICK_UP_DUST
sta DOOR_ACTIVATED
sta INVENTORY
lda #<enemy_data
sta ENEMY_DATAL
lda #>enemy_data
sta ENEMY_DATAH
; FIXME: temporary
; lda INVENTORY
; ora #INV_RED_KEY
; sta INVENTORY
; lda #$10
; sta SCORE0
lda #1
sta FIREPOWER
lda #2 ; draw twice (both pages)
sta UPDATE_STATUS
lda #7
sta HEALTH
lda #4
sta DRAW_PAGE
lda #18
sta DUKE_X
lda #0
sta DUKE_Y
lda #1
sta DUKE_DIRECTION
jsr update_status_bar
;====================================
; load level1 background
;====================================
lda #<duke1_bg_lzsa
sta LZSA_SRC_LO
lda #>duke1_bg_lzsa
sta LZSA_SRC_HI
lda #$c ; load to page $c00
jsr decompress_lzsa2_fast
;====================================
; load level1 tilemap
;====================================
lda #<level1_data_lzsa
sta LZSA_SRC_LO
lda #>level1_data_lzsa
sta LZSA_SRC_HI
lda #$90 ; load to page $9000
jsr decompress_lzsa2_fast
;====================================
; copy in tilemap subset
;====================================
lda #28
sta TILEMAP_X
lda #0
sta TILEMAP_Y
jsr copy_tilemap_subset
;====================================
;====================================
; Main LOGO loop
;====================================
;====================================
duke_loop:
; copy over background
jsr gr_copy_to_current
; draw tilemap
jsr draw_tilemap
; draw enemies
jsr draw_enemies
; draw laser
jsr draw_laser
; draw duke
jsr draw_duke
; handle door opening
jsr check_open_door
; draw a status bar
jsr draw_status_bar
jsr page_flip
jsr handle_keypress
jsr move_duke
; 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
beq do_duke_loop
jmp done_with_duke
do_duke_loop:
; delay
; lda #200
; jsr WAIT
jmp duke_loop
done_with_duke:
bit KEYRESET ; clear keypress
rts ; exit back
;==========================
; includes
;==========================
; level graphics
.include "graphics/duke_graphics.inc"
.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 "decompress_fast_v2.s"
.include "status_bar.s"
.include "keyboard.s"
.include "joystick.s"
.include "text_drawbox.s"
.include "print_help.s"
.include "quit_yn.s"
.include "level_end.s"
.include "draw_duke.s"
.include "move_duke.s"
.include "handle_laser.s"
.include "draw_tilemap.s"
.include "enemies.s"
.include "actions.s"
.include "sound_effects.s"
.include "speaker_tone.s"
level1_data_lzsa:
.incbin "maps/level1_map.lzsa"

View File

@ -151,11 +151,14 @@ copy_filename_done:
filenames:
.word intro_filename
.word duke1_filename
.word duke2_filename
intro_filename:
.byte "DUKE_TITLE",0
duke1_filename:
.byte "DUKE",0
.byte "DUKE_LEVEL1",0
duke2_filename:
.byte "DUKE_LEVEL2",0
;===================================================

View File

@ -3,11 +3,16 @@ CFLAGS = -g -Wall -O2
LZSA = ~/research/lzsa/lzsa/lzsa
all: level1_map.lzsa png2map
all: level1_map.lzsa level2_map.lzsa png2map
###
level1_map.inc: level1_map.png png2map
./png2map level1_map.png level1_map.inc
level2_map.inc: level2_map.png png2map
./png2map level2_map.png level2_map.inc
###
loadpng.o: loadpng.c loadpng.h

BIN
duke/maps/level2_map.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB