This commit is contained in:
Randy Thiemann 2023-10-20 18:09:06 +02:00
parent 0143555f36
commit 417a89fedd
7 changed files with 93 additions and 33 deletions

View File

@ -5,6 +5,7 @@ DEF MAIN_ASM EQU 1
INCLUDE "globals.asm"
INCLUDE "res/tiles.inc"
INCLUDE "res/gameplay_map.inc"
INCLUDE "res/title_map.inc"
SECTION "Globals", HRAM
@ -33,13 +34,9 @@ Main::
ld bc, TilesEnd - Tiles
call UnsafeMemCopy
; Make sure both sprites and bg use the same tile data.
ldh a, [rLCDC]
or LCDCF_BLK01
ldh [rLCDC], a
; Clear OAM.
call ClearOAM
call SetNumberSpritePositions
call CopyOAMHandler
; Zero out the ram where needed.
@ -52,7 +49,7 @@ Main::
call InitializeLCDCInterrupt
; Switch to gameplay state.
call SwitchToGameplay
call SwitchToTitle
EventLoop::
@ -68,6 +65,7 @@ EventLoop::
ldh a, [hGameState]
cp a, b
jp nz, GamePlayEventLoopHandler
jp TitleEventLoopHandler
EventLoopPostHandler::
; Wait for vblank.

View File

@ -81,8 +81,7 @@ SwitchToGameplay::
ldh [hGameState], a
; And turn the LCD back on before we start.
ldh a, [rLCDC]
or LCDCF_ON | LCDCF_BGON | LCDCF_OBJON
ld a, LCDCF_ON | LCDCF_BGON | LCDCF_OBJON | LCDCF_BLK01
ldh [rLCDC], a
; Make sure the first game loop starts just like all the future ones.
@ -306,8 +305,9 @@ gameOverMode:
; Quit
: ldh a, [hBState]
cp a, 1
jp z, $100
jr drawStaticInfo
jr nz, :+
call SwitchToTitle
jp EventLoopPostHandler
; Always draw the score, level, next piece, and held piece.

61
src/state_title.asm Normal file
View File

@ -0,0 +1,61 @@
IF !DEF(STATE_TITLE_ASM)
DEF STATE_TITLE_ASM EQU 1
INCLUDE "globals.asm"
SECTION "Title Functions", ROM0
SwitchToTitle::
; Turn the screen off if it's on.
ldh a, [rLCDC]
and LCDCF_ON
jr z, :+ ; Screen is already off.
wait_vram
xor a, a
ldh [rLCDC], a
; Load the gameplay tilemap.
: ld de, TitleScreenTilemap
ld hl, $9800
ld bc, TitleScreenTilemapEnd - TitleScreenTilemap
call UnsafeMemCopy
; Clear OAM.
call ClearOAM
call SetNumberSpritePositions
; Set up the palettes.
ld a, PALETTE_INVERTED
set_bg_palette
set_obj0_palette
set_obj1_palette
; Install the event loop handlers.
ld a, 0
ldh [hGameState], a
; And turn the LCD back on before we start.
ld a, LCDCF_ON | LCDCF_BGON | LCDCF_BLK01
ldh [rLCDC], a
; Make sure the first game loop starts just like all the future ones.
wait_vblank
wait_vblank_end
ret
TitleEventLoopHandler::
ldh a, [hStartState]
ld b, a
ldh a, [hAState]
ld c, a
ldh a, [hBState]
or a, b
or a, c
jp z, EventLoopPostHandler
call SwitchToGameplay
jp EventLoopPostHandler
ENDC

View File

@ -1,5 +1,5 @@
#Emulicious settings file
#Fri Oct 20 17:25:15 CEST 2023
#Fri Oct 20 18:08:57 CEST 2023
WindowProfilerWindowOpen=false
WindowEventViewerWindowHeight=1416
WindowEventViewerWindowDivider=876
@ -7,7 +7,7 @@ WindowMemoryTracerWindowY=631
WindowMemoryTracerWindowX=383
Update=2
AudioSync=false
DebuggerMemoryTabVisibleRect=0,0,0,0
DebuggerMemoryTabVisibleRect=0,0,583,128
WindowProfilerWindowWidth=1073
UninitializedMemoryBreakpointSuspend=true
GameBoyErrorBreakpointEnabled32=false
@ -22,7 +22,7 @@ GameBoyErrorBreakpointEnabled20=false
StretchToWindow=false
WindowProfilerWindowHeight=563
WindowTileViewerOpen=false
DebuggerWestPanelSelectedTab=0
DebuggerWestPanelSelectedTab=1
WindowMemoryTracerWindowWidth=1136
WindowPaletteViewerOpen=false
Key37=-1
@ -35,7 +35,7 @@ GameBoyErrorBreakpointEnabled17=false
Key33=-1
GameBoyErrorBreakpointEnabled16=false
Key32=-1
WindowDebuggerHeight=1896
WindowDebuggerHeight=1416
Key31=-1
Key30=-1
WindowMemoryTracerWindowHeight=289
@ -75,7 +75,7 @@ WindowMemoryTracerWindowOpen=false
SMSInputDeviceB=1
SMSInputDeviceA=1
InterruptBreakpointEnabled=false
OutlineWidth=208
OutlineWidth=550
DebuggerEventFiltersGameBoy=
GameBoyErrorBreakpointSuspend9=true
WindowMemoryEditorOpen=false
@ -92,7 +92,7 @@ GameBoyErrorBreakpointSuspend2=true
GameBoyErrorBreakpointSuspend1=true
GameBoyErrorBreakpointSuspend0=true
DebuggerConsoleLogBreakpoints=true
WindowDebuggerOpen=false
WindowDebuggerOpen=true
Gamepad1Key37=-1
Gamepad1Key36=-1
Gamepad1Key35=-1
@ -104,8 +104,8 @@ Gamepad1Key31=-1
Gamepad1Key30=-1
BankSwapAtPCBreakpointEnabled=false
DebuggerMemorySelectedTab=HRAM
WindowVideoViewerOpen=false
WindowMemoryEditorTabVisibleRect=0,0,583,128
WindowVideoViewerOpen=true
WindowMemoryEditorTabVisibleRect=0,6096,583,384
Gamepad1Key29=-1
Gamepad1Key28=-1
Gamepad1Key27=-1
@ -142,7 +142,7 @@ Gamepad1Key13=-1
Gamepad1Key12=-1
Gamepad1Key11=-1
Gamepad1Key10=-1
WindowMemoryEditorSelectedAddress=37
WindowMemoryEditorSelectedAddress=6144
WindowMemoryEditorWidth=665
GameBoyErrorBreakpointCondition9=
GameBoyErrorBreakpointCondition8=
@ -161,13 +161,13 @@ Gamepad0Key35=-1
Gamepad0Key34=-1
Gamepad0Key33=-1
Gamepad0Key32=-1
WindowMemoryEditorSelectedTab=HRAM
WindowMemoryEditorSelectedTab=VRAM
Gamepad0Key31=-1
Gamepad0Key30=-1
SMSGamepadAThreshold=50
WindowPaletteViewerHeight=313
WindowVideoViewerY=674
WindowVideoViewerX=2606
WindowVideoViewerY=474
WindowVideoViewerX=2578
UninitializedMemoryBreakpointEnabled=false
Gamepad0Key29=-1
Gamepad0Key28=-1
@ -179,13 +179,13 @@ Gamepad0Key23=-1
Gamepad0Key22=-1
DebuggerHideToolbar=false
Gamepad0Key21=-1
WindowDebuggerWidth=1096
WindowDebuggerWidth=2576
Gamepad0Key20=-1
DebuggerSouthPanelSelectedTab=1
WindowEmuliciousWidth=816
WindowVideoViewerWidth=980
WindowMemoryEditorY=695
WindowMemoryEditorX=243
WindowMemoryEditorY=1009
WindowMemoryEditorX=2715
Gamepad0Key19=-1
Gamepad0Key18=-1
Gamepad0Key17=-1
@ -197,7 +197,7 @@ FontSize=13
Gamepad0Key12=-1
Gamepad0Key11=-1
Gamepad0Key10=-1
StackWidth=685
StackWidth=2165
BankSwapAtPCBreakpointSuspend=true
WindowEmuliciousHeight=781
WindowSpriteViewerHeight=527
@ -205,8 +205,8 @@ GameBoyErrorBreakpointMessage32=
InterruptBreakpointCondition=
Recent0=C\:\\workspace\\dmgtris\\bin\\out.gb
GameBoyErrorBreakpointMessage20=
WindowEmuliciousY=367
WindowEmuliciousX=982
WindowEmuliciousY=445
WindowEmuliciousX=1412
GameBoyErrorBreakpointEnabled9=false
GameBoyErrorBreakpointEnabled8=false
GameBoyErrorBreakpointEnabled7=false
@ -271,7 +271,7 @@ Gamepad0Key2=-1
Gamepad0Key1=-1
Gamepad0Key0=-1
WindowDebuggerY=-8
WindowDebuggerX=2552
WindowDebuggerX=-8
InterruptBreakpointSuspend=true
SMSGamepadAKeyboard=false
GameBoyErrorBreakpointSuspend32=true
@ -282,12 +282,12 @@ WindowEventViewerWindowWidth=2576
WindowRAMWatchWindowOpen=false
BankSwapAtPCBreakpointCondition=
GameBoyErrorBreakpointSuspend20=true
SouthPanelHeight=1544
SouthPanelHeight=1064
SMSbuttonsKeyboard=false
StackSplitLocation=774
StackSplitLocation=534
WindowMemoryEditorHeight=534
WindowTilemapViewerWidth=404
GBGamepadKeyboard=false
WindowTilemapViewerWidth=404
UninitializedMemoryBreakpointCondition=
GameBoyErrorBreakpointSuspend19=true
GameBoyErrorBreakpointSuspend18=true
@ -299,5 +299,5 @@ WindowSpriteViewerOpen=false
WindowProfilerWindowY=639
WindowProfilerWindowX=461
Scale=5.0
KeyboardRequireWindowFocus=true
WindowProfilerWindowProcedureProfiler=true
KeyboardRequireWindowFocus=true

1
tools/projects/out.bps Normal file
View File

@ -0,0 +1 @@
type=instruction address=gameOverMode%20+%2079 end=gameOverMode%20+%2081 enabled=true suspend=true condition= message=

BIN
tools/sstates/out.sn5 Normal file

Binary file not shown.

BIN
tools/sstates/out.sn8 Normal file

Binary file not shown.