diff --git a/gamemanager.s b/gamemanager.s index 7aa8c4c..b33864c 100644 --- a/gamemanager.s +++ b/gamemanager.s @@ -64,6 +64,7 @@ beginGameplay: jsl renderTerrainSpans gameplayLoop: + jsr kbdScan jsr syncVBL BORDER_COLOR #$0 @@ -75,9 +76,6 @@ gameplayLoop: lda projectileActive bpl gameplayLoopShotTracking ; Skip input during shots - ; Check for keys down - jsr kbdScan - ; Check for pause ; lda paused ; bne gameplayLoopEndFrame @@ -150,9 +148,14 @@ gameplayLoopProjectilesSkip: gameplayLoopVictoryCondition: lda gameOver - bmi gameplayLoopEndFrame + bmi gameplayEndTurnCondition jsr endGame +gameplayEndTurnCondition: + lda turnRequested + beq gameplayLoopEndFrame + jsr endTurn + gameplayLoopEndFrame: lda quitRequested beq gameplayLoopContinue @@ -358,8 +361,6 @@ projectilesDirty: .word 1 inventoryDirty: .word 1 -activePlayer: - .word 0 currentPlayer: .word 0 gameOver: diff --git a/graphics.s b/graphics.s index 5e0f33f..65089f2 100644 --- a/graphics.s +++ b/graphics.s @@ -268,18 +268,21 @@ waitVBL: bpl waitVBL rts + ; The Apple version, taken from GS Tech Note 039 ; syncVBL: + ;sei BITS8 syncVBL0: - lda $E0C02F + ldaA $C02f asl ; VA is now in the Carry flag - lda $E0C02E + ldaA $C02e rol ; Roll Carry into bit 0 cmp #200 ; A now contains line number - bne syncVBL0 + blt syncVBL0 BITS16 + ;cli rts ; The old style //e version diff --git a/gscats.2mg b/gscats.2mg index cb73e5a..0571114 100644 Binary files a/gscats.2mg and b/gscats.2mg differ diff --git a/loader.s b/loader.s index 865cd83..e1efc95 100644 --- a/loader.s +++ b/loader.s @@ -72,9 +72,25 @@ main: ldy #$800 ; Must match terrain_e1 .org jsr copyBytes + ; Copy vram table into bank E1 + phb + lda #vramRowInvertedSpanLookupEnd-vramRowInvertedSpanLookup-1 + ldx #vramRowInvertedSpanLookupEnd-1 + ldy #$16C0 + vramRowInvertedSpanLookupEnd-vramRowInvertedSpanLookup-1 ; Must match terrain_e1 vramRowInvertedSpanLookup + mvp $e1,$00 ; Note that ca65 reverses src,dest. Grrr. + plb + EMULATION + jmp loadData + + ; Mystery jump table at 1680 - 16BB + +ioError: + brk + ;;;;;;;;;;;;;;;;;;;;; +loadData: ; Open the sprite bank file jsr PRODOS @@ -114,8 +130,21 @@ returnToProDOS: EMULATION rts -ioError: - brk + +; This table lives here in the loader because we need to copy +; it to a specific free hole in bank E1 +vramRowInvertedSpanLookup: + .word $9d00,$9c60,$9bc0,$9b20,$9a80,$99e0,$9940,$98a0,$9800,$9760,$96c0,$9620,$9580,$94e0,$9440,$93a0,$9300,$9260,$91c0,$9120 + .word $9080,$8fe0,$8f40,$8ea0,$8e00,$8d60,$8cc0,$8c20,$8b80,$8ae0,$8a40,$89a0,$8900,$8860,$87c0,$8720,$8680,$85e0,$8540,$84a0 + .word $8400,$8360,$82c0,$8220,$8180,$80e0,$8040,$7fa0,$7f00,$7e60,$7dc0,$7d20,$7c80,$7be0,$7b40,$7aa0,$7a00,$7960,$78c0,$7820 + .word $7780,$76e0,$7640,$75a0,$7500,$7460,$73c0,$7320,$7280,$71e0,$7140,$70a0,$7000,$6f60,$6ec0,$6e20,$6d80,$6ce0,$6c40,$6ba0 + .word $6b00,$6a60,$69c0,$6920,$6880,$67e0,$6740,$66a0,$6600,$6560,$64c0,$6420,$6380,$62e0,$6240,$61a0,$6100,$6060,$5fc0,$5f20 + .word $5e80,$5de0,$5d40,$5ca0,$5c00,$5b60,$5ac0,$5a20,$5980,$58e0,$5840,$57a0,$5700,$5660,$55c0,$5520,$5480,$53e0,$5340,$52a0 + .word $5200,$5160,$50c0,$5020,$4f80,$4ee0,$4e40,$4da0,$4d00,$4c60,$4bc0,$4b20,$4a80,$49e0,$4940,$48a0,$4800,$4760,$46c0,$4620 + .word $4580,$44e0,$4440,$43a0,$4300,$4260,$41c0,$4120,$4080,$3fe0,$3f40,$3ea0,$3e00,$3d60,$3cc0,$3c20,$3b80,$3ae0,$3a40,$39a0 + .word $3900,$3860,$37c0,$3720,$3680,$35e0,$3540,$34a0,$3400,$3360,$32c0,$3220,$3180,$30e0,$3040,$2fa0,$2f00,$2e60,$2dc0,$2d20 + .word $2c80,$2be0,$2b40,$2aa0,$2a00,$2960,$28c0,$2820,$2780,$26e0,$2640,$25a0,$2500,$2460,$23c0,$2320,$2280,$21e0,$2140,$20a0 +vramRowInvertedSpanLookupEnd: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/macros.s b/macros.s index a81375f..49e66ae 100644 --- a/macros.s +++ b/macros.s @@ -169,6 +169,12 @@ .dbyt (((Arg & $FF00) | $AA00) & $EE00) | (((Arg & $00FF) | $00AA) & $00EE) .endmacro +.macro ldaA Arg ; Forces 24-bit absolute addressing to bank $00 + .byte $af + .word Arg + .byte $00 +.endmacro + .macro BREAK pha lda breakpoint diff --git a/terrain_e1.s b/terrain_e1.s index 2ffd832..013a857 100644 --- a/terrain_e1.s +++ b/terrain_e1.s @@ -278,19 +278,7 @@ terrainSpanData: .endrepeat -vramRowInvertedSpanLookup: - .word $9d00,$9c60,$9bc0,$9b20,$9a80,$99e0,$9940,$98a0,$9800,$9760,$96c0,$9620,$9580,$94e0,$9440,$93a0,$9300,$9260,$91c0,$9120 - .word $9080,$8fe0,$8f40,$8ea0,$8e00,$8d60,$8cc0,$8c20,$8b80,$8ae0,$8a40,$89a0,$8900,$8860,$87c0,$8720,$8680,$85e0,$8540,$84a0 - .word $8400,$8360,$82c0,$8220,$8180,$80e0,$8040,$7fa0,$7f00,$7e60,$7dc0,$7d20,$7c80,$7be0,$7b40,$7aa0,$7a00,$7960,$78c0,$7820 - .word $7780,$76e0,$7640,$75a0,$7500,$7460,$73c0,$7320,$7280,$71e0,$7140,$70a0,$7000,$6f60,$6ec0,$6e20,$6d80,$6ce0,$6c40,$6ba0 - .word $6b00,$6a60,$69c0,$6920,$6880,$67e0,$6740,$66a0,$6600,$6560,$64c0,$6420,$6380,$62e0,$6240,$61a0,$6100,$6060,$5fc0,$5f20 - .word $5e80,$5de0,$5d40,$5ca0,$5c00,$5b60,$5ac0,$5a20,$5980,$58e0,$5840,$57a0,$5700,$5660,$55c0,$5520,$5480,$53e0,$5340,$52a0 - .word $5200,$5160,$50c0,$5020,$4f80,$4ee0,$4e40,$4da0,$4d00,$4c60,$4bc0,$4b20,$4a80,$49e0,$4940,$48a0,$4800,$4760,$46c0,$4620 - .word $4580,$44e0,$4440,$43a0,$4300,$4260,$41c0,$4120,$4080,$3fe0,$3f40,$3ea0,$3e00,$3d60,$3cc0,$3c20,$3b80,$3ae0,$3a40,$39a0 - .word $3900,$3860,$37c0,$3720,$3680,$35e0,$3540,$34a0,$3400,$3360,$32c0,$3220,$3180,$30e0,$3040,$2fa0,$2f00,$2e60,$2dc0,$2d20 - .word $2c80,$2be0,$2b40,$2aa0,$2a00,$2960,$28c0,$2820,$2780,$26e0,$2640,$25a0,$2500,$2460,$23c0,$2320,$2280,$21e0,$2140,$20a0 - - +vramRowInvertedSpanLookup = $16C0 ; This table is copied to here by the loader .export renderTerrainSpans diff --git a/utility.s b/utility.s index 43441f2..aa76f73 100644 --- a/utility.s +++ b/utility.s @@ -152,3 +152,30 @@ mult88: jsr mult16 ; Result is 8.8 rts + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; delayShort +; Sleeps for a teeny bit +; +delayShort: + SAVE_AXY + + ldy #$01 ; Loop a bit +delayShortOuter: + ldx #$ff +delayShortInner: + nop + nop + nop + nop + nop + nop + nop + dex + bne delayShortInner + dey + bne delayShortOuter + + RESTORE_AXY + rts