From fa73dc3a2b03a1c7e5a74fbf5939ee0e024045da Mon Sep 17 00:00:00 2001 From: Randy Thiemann Date: Sat, 21 Oct 2023 14:33:18 +0200 Subject: [PATCH] Add toggle. --- src/constants.asm | 10 ++++++-- src/include/globals.asm | 4 ++++ src/sprites.asm | 2 +- src/state_gameplay.asm | 26 +++++++++++++++++---- src/state_title.asm | 52 ++++++++++++++++++++++++++++++++++++++++- tools/Emulicious.ini | 10 ++++---- 6 files changed, 90 insertions(+), 14 deletions(-) diff --git a/src/constants.asm b/src/constants.asm index 445703b..f74abdb 100644 --- a/src/constants.asm +++ b/src/constants.asm @@ -40,14 +40,20 @@ CHARMAP "Y", 100 CHARMAP "Z", 101 CHARMAP "!", 102 CHARMAP "?", 103 +CHARMAP "[", 129 +CHARMAP "]", 130 +CHARMAP "/", 128 +CHARMAP "-", 127 +CHARMAP "|", 126 +CHARMAP "#", 125 SECTION "Static Data", ROM0 sLeady:: db " READY? " sGo:: db " GO " sGameOver:: db "GAME OVER!" -sGameOver2:: db " RETRY A " -sGameOver3:: db " QUIT B " +sGameOver2:: db " RETRY[A] " +sGameOver3:: db " QUIT [B] " sPieceXOffsets:: ; How to draw each piece. X-offsets of the sprites. db 0, 8, 16, 24 ; I db 0, 8, 8, 16 ; Z diff --git a/src/include/globals.asm b/src/include/globals.asm index 9c6904c..18ee02e 100644 --- a/src/include/globals.asm +++ b/src/include/globals.asm @@ -91,12 +91,16 @@ DEF PALETTE_LIGHTER_0 EQU %11100100 DEF PALETTE_LIGHTER_1 EQU %10010000 DEF PALETTE_LIGHTER_2 EQU %01000000 DEF PALETTE_LIGHTER_3 EQU %00000000 +DEF TITLE_A EQU $99ED +DEF TITLE_B EQU $99EF DEF FIELD_TOP_LEFT EQU $9800+1 DEF TILE_FIELD_EMPTY EQU 4 DEF TILE_PIECE_0 EQU 10 DEF TILE_0 EQU 66 DEF TILE_CLEARING EQU 124 DEF TILE_GHOST EQU 125 +DEF TILE_A EQU 76 +DEF TILE_B EQU 77 DEF NEXT_BASE_X EQU 120 DEF NEXT_BASE_Y EQU 40 DEF HOLD_BASE_X EQU 120 diff --git a/src/sprites.asm b/src/sprites.asm index cef34e8..a410e36 100644 --- a/src/sprites.asm +++ b/src/sprites.asm @@ -53,7 +53,7 @@ OAMDMA:: ldh a, [hGameState] cp a, b jp nz, BlitField - jp EventLoop + jp TitleVBlankHandler ENDL OAMDMAEnd:: diff --git a/src/state_gameplay.asm b/src/state_gameplay.asm index f4a8741..e74d3e7 100644 --- a/src/state_gameplay.asm +++ b/src/state_gameplay.asm @@ -191,7 +191,7 @@ fetchPieceMode: .cp1 cp a, 0 jr z, .checkIRSB - ld a, 1 + ld a, 3 ldh [hCurrentPieceRotationState], a ld a, SFX_IRS call SFXEnqueue @@ -202,13 +202,13 @@ fetchPieceMode: jr z, .ldb2 .lda2 ld a, [hAState] - jr .cp1 + jr .cp2 .ldb2 ld a, [hBState] .cp2 cp a, 0 jr z, .checkJingle - ld a, 3 + ld a, 1 ldh [hCurrentPieceRotationState], a ld a, SFX_IRS call SFXEnqueue @@ -359,19 +359,35 @@ DoHold: ; Check if IRS is requested. ; Apply the rotation if so. .checkIRSHA + ld a, [hSwapAB] + cp a, 0 + jr z, .lda3 +.ldb3 + ld a, [hBState] + jr .cp3 +.lda3 ld a, [hAState] +.cp3 cp a, 0 jr z, .checkIRSHB - ld a, 1 + ld a, 3 ldh [hCurrentPieceRotationState], a ld a, SFX_IRS call SFXEnqueue .checkIRSHB + ld a, [hSwapAB] + cp a, 0 + jr z, .ldb4 +.lda4 + ld a, [hAState] + jr .cp4 +.ldb4 ld a, [hBState] +.cp4 cp a, 0 jr z, .noRotation - ld a, 3 + ld a, 1 ldh [hCurrentPieceRotationState], a ld a, SFX_IRS call SFXEnqueue diff --git a/src/state_title.asm b/src/state_title.asm index 3eb4f81..6dd210d 100644 --- a/src/state_title.asm +++ b/src/state_title.asm @@ -46,6 +46,7 @@ SwitchToTitle:: TitleEventLoopHandler:: + ; Start game? ldh a, [hStartState] ld b, a ldh a, [hAState] @@ -54,9 +55,58 @@ TitleEventLoopHandler:: or a, b or a, c cp a, 1 - jp nz, EventLoopPostHandler + jr nz, :+ call SwitchToGameplay jp EventLoopPostHandler + ; Toggle A/B? +: ldh a, [hLeftState] + ld b, a + ldh a, [hRightState] + or a, b + cp a, 1 + jr nz, :+ + ldh a, [hSwapAB] + cpl + ldh [hSwapAB], a + jp EventLoopPostHandler + + ; Start level up? +: ldh a, [hUpState] + cp a, 1 + jr nz, :+ + ; TODO + jp EventLoopPostHandler + + ; Start level down? +: ldh a, [hDownState] + cp a, 1 + jr nz, :+ + ; TODO +: jp EventLoopPostHandler + + +TitleVBlankHandler:: + ldh a, [hSwapAB] + cp a, 0 + jr nz, :+ + ld hl, TITLE_A + ld a, TILE_A + ld [hl+], a + inc hl + inc a + ld [hl], a + wait_vblank_end + jp EventLoop + +: ld hl, TITLE_A + ld a, TILE_B + ld [hl+], a + inc hl + dec a + ld [hl], a + wait_vblank_end + jp EventLoop + ENDC diff --git a/tools/Emulicious.ini b/tools/Emulicious.ini index b869117..5d80fc4 100644 --- a/tools/Emulicious.ini +++ b/tools/Emulicious.ini @@ -1,5 +1,5 @@ #Emulicious settings file -#Sat Oct 21 14:06:55 CEST 2023 +#Sat Oct 21 14:31:03 CEST 2023 WindowProfilerWindowOpen=false WindowEventViewerWindowHeight=1416 WindowEventViewerWindowDivider=876 @@ -7,7 +7,7 @@ WindowMemoryTracerWindowY=631 WindowMemoryTracerWindowX=383 Update=2 AudioSync=false -DebuggerMemoryTabVisibleRect=0,0,687,128 +DebuggerMemoryTabVisibleRect=0,0,0,0 WindowProfilerWindowWidth=1073 UninitializedMemoryBreakpointSuspend=true GameBoyErrorBreakpointEnabled32=false @@ -92,7 +92,7 @@ GameBoyErrorBreakpointSuspend2=true GameBoyErrorBreakpointSuspend1=true GameBoyErrorBreakpointSuspend0=true DebuggerConsoleLogBreakpoints=true -WindowDebuggerOpen=true +WindowDebuggerOpen=false Gamepad1Key37=-1 Gamepad1Key36=-1 Gamepad1Key35=-1 @@ -271,8 +271,8 @@ Gamepad0Key3=-1 Gamepad0Key2=-1 Gamepad0Key1=-1 Gamepad0Key0=-1 -WindowDebuggerY=-8 -WindowDebuggerX=-8 +WindowDebuggerY=544 +WindowDebuggerX=210 InterruptBreakpointSuspend=true SMSGamepadAKeyboard=false GameBoyErrorBreakpointSuspend32=true