2020-12-17 20:25:55 +00:00
|
|
|
; Duke Level2 -- Living Dangerously
|
2020-11-14 20:19:56 +00:00
|
|
|
|
|
|
|
; 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
|
|
|
|
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-12-15 04:53:15 +00:00
|
|
|
|
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 DUKE_WALKING
|
|
|
|
sta DUKE_JUMPING
|
|
|
|
sta LEVEL_OVER
|
|
|
|
sta LASER_OUT
|
2020-12-13 06:27:21 +00:00
|
|
|
sta DUKE_XL
|
2020-12-14 16:49:35 +00:00
|
|
|
sta DUKE_FALLING
|
2020-12-14 21:01:47 +00:00
|
|
|
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-14 03:15:20 +00:00
|
|
|
|
2020-12-16 05:06:55 +00:00
|
|
|
lda #<enemy_data
|
|
|
|
sta ENEMY_DATAL
|
|
|
|
lda #>enemy_data
|
|
|
|
sta ENEMY_DATAH
|
|
|
|
|
2020-12-14 03:15:20 +00:00
|
|
|
lda #2 ; draw twice (both pages)
|
|
|
|
sta UPDATE_STATUS
|
|
|
|
|
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
|
2020-12-16 19:56:16 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
2020-12-14 03:15:20 +00:00
|
|
|
jsr update_status_bar
|
|
|
|
|
2020-11-14 20:19:56 +00:00
|
|
|
;====================================
|
2020-12-18 00:34:02 +00:00
|
|
|
; load level2 background
|
2020-11-14 20:19:56 +00:00
|
|
|
;====================================
|
|
|
|
|
2020-12-17 20:25:55 +00:00
|
|
|
lda #<level2_bg_lzsa
|
2020-11-14 20:19:56 +00:00
|
|
|
sta LZSA_SRC_LO
|
2020-12-17 20:25:55 +00:00
|
|
|
lda #>level2_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
|
|
|
;====================================
|
2020-12-17 20:57:08 +00:00
|
|
|
; load level2 tilemap
|
2020-12-09 04:41:53 +00:00
|
|
|
;====================================
|
|
|
|
|
2020-12-17 20:25:55 +00:00
|
|
|
lda #<level2_data_lzsa
|
2020-12-09 04:41:53 +00:00
|
|
|
sta LZSA_SRC_LO
|
2020-12-17 20:25:55 +00:00
|
|
|
lda #>level2_data_lzsa
|
2020-12-09 04:41:53 +00:00
|
|
|
sta LZSA_SRC_HI
|
|
|
|
lda #$90 ; load to page $9000
|
|
|
|
jsr decompress_lzsa2_fast
|
|
|
|
|
|
|
|
;====================================
|
|
|
|
; copy in tilemap subset
|
|
|
|
;====================================
|
2020-12-17 20:25:55 +00:00
|
|
|
lda #10
|
2020-12-09 04:44:16 +00:00
|
|
|
sta TILEMAP_X
|
2020-12-17 20:57:08 +00:00
|
|
|
lda #8
|
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
|
|
|
|
;====================================
|
|
|
|
;====================================
|
|
|
|
|
2020-12-18 00:34:02 +00:00
|
|
|
jsr setup_music
|
|
|
|
|
|
|
|
lda SOUND_STATUS
|
|
|
|
bmi skip_music
|
2020-12-17 23:57:46 +00:00
|
|
|
|
|
|
|
cli ; start music
|
2020-12-18 00:34:02 +00:00
|
|
|
skip_music:
|
2020-12-17 23:57:46 +00:00
|
|
|
|
2020-11-14 20:19:56 +00:00
|
|
|
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
|
|
|
|
|
2020-12-14 21:01:47 +00:00
|
|
|
|
|
|
|
;========================
|
|
|
|
; 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-12-14 21:01:47 +00:00
|
|
|
|
|
|
|
|
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-17 22:24:00 +00:00
|
|
|
; FIXME: point to next level
|
|
|
|
lda #LOAD_TITLE
|
|
|
|
sta WHICH_LOAD
|
|
|
|
|
2020-12-18 00:34:02 +00:00
|
|
|
sei ; stop music
|
|
|
|
|
2020-12-15 15:19:46 +00:00
|
|
|
rts ; exit back
|
|
|
|
|
2020-11-14 20:19:56 +00:00
|
|
|
|
|
|
|
;==========================
|
|
|
|
; includes
|
|
|
|
;==========================
|
|
|
|
|
|
|
|
; level graphics
|
2020-12-17 20:25:55 +00:00
|
|
|
.include "graphics/level2_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"
|
2020-12-17 21:48:18 +00:00
|
|
|
.include "duke_l2_sprites.inc"
|
2020-12-14 21:01:47 +00:00
|
|
|
.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-17 20:57:08 +00:00
|
|
|
.include "enemies_level2.s"
|
|
|
|
.include "actions_level2.s"
|
2020-12-17 23:57:46 +00:00
|
|
|
.include "item_level2.s"
|
2020-11-28 05:51:57 +00:00
|
|
|
|
2020-12-14 15:44:31 +00:00
|
|
|
.include "sound_effects.s"
|
2020-12-16 18:31:23 +00:00
|
|
|
.include "speaker_tone.s"
|
2020-12-14 15:44:31 +00:00
|
|
|
|
2020-12-17 20:25:55 +00:00
|
|
|
level2_data_lzsa:
|
|
|
|
.incbin "maps/level2_map.lzsa"
|
2020-12-17 23:57:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
.include "duke_music.s"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|