From af488e4b26ededeab18a1e1e5a86eb7716537d0d Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Sun, 13 Dec 2020 22:15:20 -0500 Subject: [PATCH] duke: have status bar actually update not sure why I bother as you can't do anything that affects this yet --- duke/TODO | 36 ++++++++----- duke/duke.s | 17 ++++++ duke/status_bar.s | 132 ++++++++++++++++++++++++++++++++++++++++++---- duke/text_print.s | 17 ++++++ duke/zp.inc | 12 +++++ 5 files changed, 191 insertions(+), 23 deletions(-) diff --git a/duke/TODO b/duke/TODO index 78b4004c..b8608c58 100644 --- a/duke/TODO +++ b/duke/TODO @@ -1,24 +1,34 @@ -collision detection left/right +sound: +~~~~~~ +click on jump +click on bump head +fancier PC-style sounds + +movement: +~~~~~~~~~ collision detection up (hit head on jump) - only calculate position once only jump if feet on ground -speed up walking again +when land from jump, stop walking jump slightly higher? - -hook up title screen - +levels: +~~~~~~~ mystery level 2 -more complete map - -status: keep score, proper laser count +status: +~~~~~~~ +keep score, proper laser count +sprites: +~~~~~~~~ Different sprites for left, right, shooting When land, kicks up dust -Enemy? Little robot, green crawly +enemies: +~~~~~~~~ +Little robot +green crawly -Sound effects? - -Pick up items? red key inverse-R +items: +~~~~~~ +red/blue key inverse-R diff --git a/duke/duke.s b/duke/duke.s index 99ae9797..975e89ee 100644 --- a/duke/duke.s +++ b/duke/duke.s @@ -38,6 +38,21 @@ duke_start: sta LEVEL_OVER sta LASER_OUT sta DUKE_XL + sta SCORE1 + sta SCORE2 + 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 @@ -50,6 +65,8 @@ duke_start: sta DUKE_DIRECTION + jsr update_status_bar + ;==================================== ; load level1 background ;==================================== diff --git a/duke/status_bar.s b/duke/status_bar.s index 612984bf..91c7e59e 100644 --- a/duke/status_bar.s +++ b/duke/status_bar.s @@ -1,23 +1,128 @@ ; Draw Status Bar -update_status_bar: + ;=========================== + ; inc_score_by_10 + ;=========================== + ; FIXME: make sure interrupt routine handles d flag properly +inc_score_by_10: + + sed + lda SCORE0 + clc + adc #$10 + sta SCORE0 + + lda SCORE1 + adc #0 + sta SCORE1 + + lda SCORE2 + adc #0 + sta SCORE2 + cld + + jsr update_score + rts + ;=========================== + ; update score + ;=========================== + +update_score: + + lda SCORE0 + and #$f + ora #$b0 ; 0 -> $b0 + sta status_string+6 + + lda SCORE0 + lsr + lsr + lsr + lsr + ora #$b0 ; 0 -> $b0 + sta status_string+5 + + lda SCORE1 + and #$f + ora #$b0 ; 0 -> $b0 + sta status_string+4 + + lda SCORE1 + lsr + lsr + lsr + lsr + ora #$b0 ; 0 -> $b0 + sta status_string+3 + + lda SCORE2 + and #$f + ora #$b0 ; 0 -> $b0 + sta status_string+2 + + lda #2 + sta UPDATE_STATUS + + rts + + + ;=========================== + ; update health + ;=========================== + +update_health: + + ldx #0 +update_health_loop: + cpx HEALTH + bcc health_on + lda #'_'|$80 + bne done_health +health_on: + lda #' ' +done_health: + sta status_string+9,X + + inx + cpx #8 + bne update_health_loop + + rts + + + + ;=========================== + ; update the status bar + ;=========================== +update_status_bar: + + jsr update_score + + jsr update_health + + rts + + ;=========================== + ; draw the status bar + ;=========================== draw_status_bar: - jsr inverse_text + ; to improve frame rate, only draw if update status set? + ; not implemented yet + + jsr inverse_text ; print help node lda #help_string sta OUTH jsr move_and_print - jsr normal_text - jsr move_and_print - jsr move_and_print - - jsr inverse_text - jsr move_and_print + jsr normal_text ; (normal) + jsr move_and_print ; print explain text + jsr raw_text + jsr move_and_print ; print status line rts @@ -27,5 +132,12 @@ help_string: score_string: ; 012456789012345678901234567890123456789 .byte 0,22,"SCORE HEALTH FIREPOWER INVENTORY",0 - .byte 0,23,"00010 XXXXXXXX =-=- ",0 - .byte 7,23," ",0 +status_string: +; .byte 0,23,"ZZZZZ XXXXXXXX =- ",0 + .byte 0,23,"ZZZZZ" + .byte ' '|$80,' '|$80 + .byte "XXXXXXXX" + .byte ' '|$80,' '|$80 + .byte '='|$80,'-'|$80,' '|$80,' '|$80,' '|$80,' '|$80,' '|$80,' '|$80,' '|$80,' '|$80 + .byte ' '|$80,' '|$80,' '|$80,' '|$80,' '|$80,' '|$80,' '|$80,' '|$80,' '|$80,' '|$80,' '|$80,' '|$80,0 + diff --git a/duke/text_print.s b/duke/text_print.s index 0ff20932..dada5ca0 100644 --- a/duke/text_print.s +++ b/duke/text_print.s @@ -29,6 +29,23 @@ inverse_text: rts + ;============================= + ; raw text + ;============================= + ; modify so print raw string +raw_text: + + ; want nop nop + lda #$EA + sta ps_smc1 + + lda #$EA + sta ps_smc1+1 + + rts + + + ;================================ ; move_and_print ;================================ diff --git a/duke/zp.inc b/duke/zp.inc index 7c614e10..7e3c96bb 100644 --- a/duke/zp.inc +++ b/duke/zp.inc @@ -95,6 +95,18 @@ TILEMAP_Y = $8C DUKE_FOOT_OFFSET = $8D +FIREPOWER = $8E +INVENTORY = $8F + INV_RED_KEY = $80 + INV_BLUE_KEY = $20 + INV_SHOE = $08 + INV_GRIP = $02 +HEALTH = $90 +SCORE0 = $91 +SCORE1 = $92 +SCORE2 = $93 +UPDATE_STATUS = $94 + ; done game puzzle state