diff --git a/duke/TODO b/duke/TODO index 6f0944b5..08f13c39 100644 --- a/duke/TODO +++ b/duke/TODO @@ -7,7 +7,7 @@ key pickup noise * NO BONUS message * back to title screen * are you sure message on quit -scroll bonus message +* scroll bonus message sound: ~~~~~~ @@ -24,8 +24,7 @@ walking right into objects, stand back one more (maybe and to mask?) level1: ~~~~~~~ -exit door, blue pillar, red key (all in basement?) - +blue pillar? tiles ~~~~~ @@ -52,6 +51,7 @@ enemies: ~~~~~~~~ Little robot green crawly +ability to die items: ~~~~~~ diff --git a/duke/actions.s b/duke/actions.s index 999835d7..9e3bd21b 100644 --- a/duke/actions.s +++ b/duke/actions.s @@ -3,9 +3,48 @@ up_action: + + ; set X and Y value + ; convert tile values to X,Y + ; X=((DUKE_X/2)-1)+TILEX + + lda DUKE_X + lsr + sec + sbc #1 + clc + adc TILEMAP_X + sta XPOS + + ; Y = (DUKEY/4)+TILEY + lda DUKE_Y + lsr + lsr + clc + adc TILEMAP_Y + sta YPOS + + ; $39,$22 = 57,34 + ; check if it's a key slot check_red_keyhole: + + ; key slot is 280,148 + ; 280,148 (-80,-12) -> 200,136 -> (/4,/4) -> 50,34 + + lda XPOS + cmp #50 + beq redkey_x + cmp #51 + bne check_if_exit + +redkey_x: + + lda YPOS + cmp #34 + bne check_if_exit + ; check that we have the key lda INVENTORY and #INV_RED_KEY @@ -44,11 +83,116 @@ not_red_tile: jsr copy_tilemap_subset + jmp done_up_action + ; check if it's the exit check_if_exit: + ; exit is 296,148 + ; 296,148 (-80,-12) -> 216,136 -> (/4,/4) -> 54,34 + + lda XPOS + cmp #54 + beq exit_x + + cmp #55 + bne done_up_action + +exit_x: + lda YPOS + cmp #34 + bne done_up_action + + ; check that we have the key + lda INVENTORY + and #INV_RED_KEY + beq done_up_action + + lda #1 + sta DOOR_ACTIVATED + + sta FRAMEL ; restart timer done_up_action: rts + + + ;========================== + ; open the door, end level + ;========================== +check_open_door: + lda DOOR_ACTIVATED + beq done_open_door + + asl + tay + lda door_opening,Y + sta INL + lda door_opening+1,Y + sta INH + + ; need to find actual door location + ; it's at 54,34 + ; Y is going to be at 20 unless something weird is going on + ; X is going to be ((54-TILE_X)+2)*2 + + lda #56 + sec + sbc TILEMAP_X + asl + sta XPOS + + lda #20 + sta YPOS + + jsr put_sprite_crop + + lda FRAMEL + and #$7 + bne done_open_door + + ; increment + + inc DOOR_ACTIVATED + lda DOOR_ACTIVATED + cmp #6 + bne done_open_door + + jsr level_end + +done_open_door: + rts + + + +door_opening: + .word door_sprite0 + .word door_sprite0 + .word door_sprite1 + .word door_sprite2 + .word door_sprite1 + .word door_sprite0 + +door_sprite0: + .byte 4,4 + .byte $15,$55,$55,$f5 + .byte $55,$f5,$5f,$55 + .byte $25,$25,$25,$25 + .byte $55,$55,$55,$55 + +door_sprite1: + .byte 4,4 + .byte $51,$f5,$f5,$5f + .byte $55,$05,$05,$50 + .byte $05,$50,$50,$55 + .byte $52,$55,$55,$52 + +door_sprite2: + .byte 4,4 + .byte $f5,$05,$05,$f0 + .byte $55,$00,$00,$55 + .byte $55,$00,$00,$55 + .byte $05,$50,$50,$25 + diff --git a/duke/duke.s b/duke/duke.s index a3c2a331..3def8274 100644 --- a/duke/duke.s +++ b/duke/duke.s @@ -45,6 +45,7 @@ duke_start: sta DUKE_FALLING sta DUKE_SHOOTING sta KICK_UP_DUST + sta DOOR_ACTIVATED lda #