dos33fsprogs/duke/duke_level2.s

238 lines
3.4 KiB
ArmAsm
Raw Normal View History

2020-11-14 20:19:56 +00:00
; Duke PoC
; by deater (Vince Weaver) <vince@deater.net>
; Zero Page
.include "zp.inc"
.include "hardware.inc"
2020-12-15 15:19:46 +00:00
.include "common_defines.inc"
2020-12-09 04:41:53 +00:00
TILES = $9000
BIG_TILEMAP = $9400
TILEMAP = $BC00
2020-11-14 20:19:56 +00:00
duke_start:
;===================
; init screen
jsr TEXT
jsr HOME
bit KEYRESET
bit SET_GR
bit PAGE0
bit LORES
bit TEXTGR
2020-12-15 05:37:59 +00:00
jsr clear_top ; avoid grey stripes at load
2020-11-28 05:51:57 +00:00
;=====================
; init vars
;=====================
2020-11-14 20:19:56 +00:00
lda #0
sta ANIMATE_FRAME
sta FRAMEL
sta FRAMEH
sta DISP_PAGE
2020-11-28 05:51:57 +00:00
sta JOYSTICK_ENABLED
sta DUKE_WALKING
sta DUKE_JUMPING
sta LEVEL_OVER
sta LASER_OUT
2020-12-13 06:27:21 +00:00
sta DUKE_XL
2020-12-16 19:44:50 +00:00
sta SCORE0
sta SCORE1
sta SCORE2
2020-12-14 16:49:35 +00:00
sta DUKE_FALLING
sta DUKE_SHOOTING
2020-12-15 04:37:12 +00:00
sta KICK_UP_DUST
2020-12-16 17:55:05 +00:00
sta DOOR_ACTIVATED
2020-12-16 19:44:50 +00:00
sta INVENTORY
2020-12-16 05:06:55 +00:00
lda #<enemy_data
sta ENEMY_DATAL
lda #>enemy_data
sta ENEMY_DATAH
2020-12-16 02:47:55 +00:00
; FIXME: temporary
2020-12-16 19:44:50 +00:00
; lda INVENTORY
; ora #INV_RED_KEY
; sta INVENTORY
2020-12-16 02:47:55 +00:00
2020-12-16 19:44:50 +00:00
; lda #$10
; sta SCORE0
lda #1
sta FIREPOWER
lda #2 ; draw twice (both pages)
sta UPDATE_STATUS
lda #7
sta HEALTH
2020-11-14 20:19:56 +00:00
lda #4
sta DRAW_PAGE
2020-11-28 05:51:57 +00:00
lda #18
sta DUKE_X
lda #0
2020-11-28 05:51:57 +00:00
sta DUKE_Y
lda #1
sta DUKE_DIRECTION
2020-11-14 20:19:56 +00:00
jsr update_status_bar
2020-11-14 20:19:56 +00:00
;====================================
2020-12-09 04:41:53 +00:00
; load level1 background
2020-11-14 20:19:56 +00:00
;====================================
2020-12-08 16:32:53 +00:00
lda #<duke1_bg_lzsa
2020-11-14 20:19:56 +00:00
sta LZSA_SRC_LO
2020-12-08 16:32:53 +00:00
lda #>duke1_bg_lzsa
2020-11-14 20:19:56 +00:00
sta LZSA_SRC_HI
lda #$c ; load to page $c00
jsr decompress_lzsa2_fast
2020-12-09 04:41:53 +00:00
;====================================
; 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
2020-12-09 04:44:16 +00:00
sta TILEMAP_X
lda #0
2020-12-09 04:44:16 +00:00
sta TILEMAP_Y
2020-12-09 04:41:53 +00:00
jsr copy_tilemap_subset
2020-11-14 20:19:56 +00:00
;====================================
;====================================
; Main LOGO loop
;====================================
;====================================
duke_loop:
; copy over background
jsr gr_copy_to_current
2020-12-09 00:19:23 +00:00
; draw tilemap
jsr draw_tilemap
2020-12-16 02:47:55 +00:00
; draw enemies
jsr draw_enemies
2020-11-28 05:51:57 +00:00
; draw laser
jsr draw_laser
; draw duke
jsr draw_duke
2020-12-16 17:55:05 +00:00
; handle door opening
jsr check_open_door
2020-11-28 05:51:57 +00:00
; draw a status bar
2020-11-27 02:35:16 +00:00
jsr draw_status_bar
2020-11-14 20:19:56 +00:00
jsr page_flip
2020-11-28 05:51:57 +00:00
jsr handle_keypress
2020-11-14 20:19:56 +00:00
2020-11-28 05:51:57 +00:00
jsr move_duke
2020-11-14 20:19:56 +00:00
2020-12-16 05:25:58 +00:00
; jsr move_enemies
2020-12-16 02:47:55 +00:00
2020-11-28 05:51:57 +00:00
jsr move_laser
;========================
; increment frame count
;========================
inc FRAMEL
bne no_frame_oflo
inc FRAMEH
no_frame_oflo:
2020-11-28 05:51:57 +00:00
;===========================
; check end of level
;===========================
lda LEVEL_OVER
2020-12-15 15:19:46 +00:00
beq do_duke_loop
2020-11-14 20:19:56 +00:00
jmp done_with_duke
2020-11-14 20:19:56 +00:00
do_duke_loop:
; delay
2020-11-28 05:51:57 +00:00
; lda #200
; jsr WAIT
2020-11-14 20:19:56 +00:00
jmp duke_loop
done_with_duke:
bit KEYRESET ; clear keypress
2020-12-15 15:19:46 +00:00
rts ; exit back
2020-11-14 20:19:56 +00:00
;==========================
; includes
;==========================
; level graphics
2020-12-08 16:32:53 +00:00
.include "graphics/duke_graphics.inc"
2020-11-14 20:19:56 +00:00
.include "text_print.s"
.include "gr_offsets.s"
2020-12-11 06:24:47 +00:00
.include "gr_fast_clear.s"
2020-11-14 20:19:56 +00:00
.include "gr_copy.s"
.include "gr_pageflip.s"
2020-11-28 05:51:57 +00:00
.include "gr_putsprite_crop.s"
2020-11-14 20:19:56 +00:00
.include "decompress_fast_v2.s"
2020-11-27 02:35:16 +00:00
.include "status_bar.s"
2020-11-28 05:51:57 +00:00
.include "keyboard.s"
.include "joystick.s"
2020-12-15 15:54:27 +00:00
.include "text_drawbox.s"
2020-12-11 05:44:55 +00:00
.include "print_help.s"
2020-12-15 15:19:46 +00:00
.include "quit_yn.s"
2020-12-15 16:20:23 +00:00
.include "level_end.s"
2020-11-28 05:51:57 +00:00
.include "draw_duke.s"
.include "move_duke.s"
2020-11-28 05:51:57 +00:00
.include "handle_laser.s"
2020-12-09 00:19:23 +00:00
.include "draw_tilemap.s"
2020-12-16 02:47:55 +00:00
.include "enemies.s"
2020-12-16 14:54:12 +00:00
.include "actions.s"
2020-11-28 05:51:57 +00:00
.include "sound_effects.s"
2020-12-16 18:31:23 +00:00
.include "speaker_tone.s"
2020-12-09 04:41:53 +00:00
level1_data_lzsa:
.incbin "maps/level1_map.lzsa"