Compare commits

..

No commits in common. "ed3ae01250f354a42163d803af80694dc1502623" and "313a97265f4bdc0c7cc498a99ec6b873ee26faa0" have entirely different histories.

3 changed files with 25 additions and 180 deletions

View File

@ -6,76 +6,29 @@ INCLUDE "globals.asm"
SECTION "Field Variables", WRAM0 SECTION "Field Variables", WRAM0
wField:: ds (10*24) wField:: ds (10*21)
wShadowField:: ds (14*26)
SECTION "Field Functions", ROM0 SECTION "Field Functions", ROM0
FieldInit:: FieldInit::
ld hl, wField ld hl, wField
ld bc, 10*24 ld bc, 10*21
ld d, 1 ld d, 1
call UnsafeMemSet call UnsafeMemSet
ld hl, wShadowField
ld bc, 14*26
ld d, $FF
call UnsafeMemSet
ret ret
FieldClear:: FieldClear::
ld hl, wField ld hl, wField
ld bc, 10*24 ld bc, 10*21
ld d, TILE_FIELD_EMPTY ld d, TILE_FIELD_EMPTY
call UnsafeMemSet call UnsafeMemSet
ret ret
ToShadowField::
ld hl, wField
ld de, wShadowField+2
ld c, 24
.outer
ld b, 10
.inner
ld a, [hl+]
ld [de], a
inc de
dec b
jr nz, .inner
inc de
inc de
inc de
inc de
dec c
jr nz, .outer
ret
FromShadowField::
ld hl, wField
ld de, wShadowField+2
ld c, 24
.outer
ld b, 10
.inner
ld a, [de]
ld [hl+], a
inc de
dec b
jr nz, .inner
inc de
inc de
inc de
inc de
dec c
jr nz, .outer
ret
; This routine will copy wField onto the screen. ; This routine will copy wField onto the screen.
BlitField:: BlitField::
; What to copy ; What to copy
ld de, wField + 40 ld de, wField + 10
; Where to put it ; Where to put it
ld hl, FIELD_TOP_LEFT ld hl, FIELD_TOP_LEFT
; How much to increment hl after each row ; How much to increment hl after each row

View File

@ -22,8 +22,6 @@ hCurrentPieceX: ds 1
hCurrentPieceY: ds 1 hCurrentPieceY: ds 1
hCurrentPieceRotationState: ds 1 hCurrentPieceRotationState: ds 1
hHeldPiece: ds 1 hHeldPiece: ds 1
hHoldSpent: ds 1
hSkipJingle: ds 1
SECTION "Gameplay Functions", ROM0 SECTION "Gameplay Functions", ROM0
@ -64,8 +62,6 @@ SwitchToGameplay::
; We don't start with a held piece. ; We don't start with a held piece.
ld a, PIECE_NONE ld a, PIECE_NONE
ldh [hHeldPiece], a ldh [hHeldPiece], a
xor a, a
ldh [hHoldSpent], a
; Leady mode. ; Leady mode.
ld a, MODE_LEADY ld a, MODE_LEADY
@ -100,8 +96,7 @@ GamePlayEventLoopHandler::
cp MODE_FETCH_PIECE cp MODE_FETCH_PIECE
jr z, fetchPieceMode jr z, fetchPieceMode
cp MODE_SPAWN_PIECE cp MODE_SPAWN_PIECE
jp z, spawnPieceMode jr z, spawnPieceMode
; Draw "READY" and wait a bit. ; Draw "READY" and wait a bit.
leadyMode: leadyMode:
@ -118,7 +113,6 @@ leadyMode:
call UnsafeMemCopy call UnsafeMemCopy
jp drawStaticInfo jp drawStaticInfo
; Draw "GO" and wait a bit. ; Draw "GO" and wait a bit.
goMode: goMode:
ld a, [wModeCounter] ld a, [wModeCounter]
@ -134,7 +128,6 @@ goMode:
call UnsafeMemCopy call UnsafeMemCopy
jp drawStaticInfo jp drawStaticInfo
; Clear the field, ready for gameplay. ; Clear the field, ready for gameplay.
postGoMode: postGoMode:
ld a, MODE_FETCH_PIECE ld a, MODE_FETCH_PIECE
@ -142,74 +135,31 @@ postGoMode:
call FieldClear call FieldClear
jp drawStaticInfo jp drawStaticInfo
; Fetch the next piece. ; Fetch the next piece.
fetchPieceMode: fetchPieceMode:
ld a, [wNextPiece] ld a, [wNextPiece]
ldh [hCurrentPiece], a ldh [hCurrentPiece], a
call GetNextPiece call GetNextPiece
; A piece will spawn in the middle, at the top of the screen, not rotated by default. ; Check if IRS is charged.
ld a, 5
ldh [hCurrentPieceX], a
ld a, 3
ldh [hCurrentPieceY], a
xor a, a
ldh [hSkipJingle], a
ldh [hCurrentPieceRotationState], a
ldh [hHoldSpent], a
; Check if IHS is requested.
; Apply the hold if so.
.checkIHS
ld a, [hSelectState]
cp a, 0
jr z, .checkIRSA
call DoHold
; Holding does its own IRS check.
jr .checkJingle
; Check if IRS is requested.
; Apply the rotation if so.
.checkIRSA
ld a, [hAState] ld a, [hAState]
cp a, 0 ld b, a
jr z, .checkIRSB
ld a, 1
ldh [hCurrentPieceRotationState], a
ld a, SFX_IRS
call SFXEnqueue
.checkIRSB
ld a, [hBState] ld a, [hBState]
cp a, 0 or a, b
jr z, .checkJingle jr z, :+
ld a, 3
ldh [hCurrentPieceRotationState], a
ld a, SFX_IRS ld a, SFX_IRS
call SFXEnqueue call SFXEnqueue
.checkJingle : ld a, [wNextPiece]
ld a, [hSkipJingle]
cp a, 0
jr nz, .skipJingle
.playNextJingle
ld a, [wNextPiece]
call SFXEnqueue call SFXEnqueue
.skipJingle
ld a, MODE_SPAWN_PIECE ld a, MODE_SPAWN_PIECE
ld [wMode], a ld [wMode], a
; State falls through to the next. jp drawStaticInfo
; Spawn the piece. ; Spawn the piece.
spawnPieceMode: spawnPieceMode:
; TODO: At this point all the info needed to spawn the piece is known. ; todo
; We spawn the piece and then check if this causes a top out, and transition to the game over state if so.
; This then immediately transitions into regular gameplay.
call ToShadowField
call FromShadowField
ld a, [hEvenFrame] ld a, [hEvenFrame]
cp a, 0 cp a, 0
@ -226,7 +176,7 @@ spawnPieceMode:
jr nz, :+ jr nz, :+
ld a, MODE_FETCH_PIECE ld a, MODE_FETCH_PIECE
ld [wMode], a ld [wMode], a
jr drawStaticInfo jp drawStaticInfo
: ld a, [hLeftState] : ld a, [hLeftState]
cp a, 1 cp a, 1
@ -238,20 +188,14 @@ spawnPieceMode:
jr z, :++ jr z, :++
cp a, 12 cp a, 12
jr nc, :+ jr nc, :+
jr drawStaticInfo jp drawStaticInfo
: ldh a, [hFrameCtr] : ldh a, [hFrameCtr]
and %00000111 and %00000111
cp 4 cp 4
jr nz, drawStaticInfo jp nz, drawStaticInfo
: ld a, SFX_MOVE : ld a, SFX_MOVE
call SFXEnqueue call SFXEnqueue
jr drawStaticInfo jp drawStaticInfo
; This mode lasts for as long as the piece is in motion.
; Field will let us know when it has locked in place.
pieceInMotionMode:
; TODO.
; Always draw the score, level, next piece, and held piece. ; Always draw the score, level, next piece, and held piece.
@ -277,56 +221,4 @@ drawStaticInfo:
jp EventLoopPostHandler jp EventLoopPostHandler
DoHold:
; Mark hold as spent.
ld a, $FF
ldh [hHoldSpent], a
; Check if IRS is requested.
; Apply the rotation if so.
.checkIRSHA
ld a, [hAState]
cp a, 0
jr z, .checkIRSHB
ld a, 1
ldh [hCurrentPieceRotationState], a
ld a, SFX_IRS
call SFXEnqueue
.checkIRSHB
ld a, [hBState]
cp a, 0
jr z, .noRotation
ld a, 3
ldh [hCurrentPieceRotationState], a
ld a, SFX_IRS
call SFXEnqueue
jr .doHoldOperation
.noRotation
ld a, 0
ldh [hCurrentPieceRotationState], a
.doHoldOperation
; If we're not holding a piece, hold the current piece and get a new one.
ldh a, [hHeldPiece]
cp a, PIECE_NONE
jr nz, :+
ldh a, [hCurrentPiece]
ldh [hHeldPiece], a
ld a, [wNextPiece]
ldh [hCurrentPiece], a
call GetNextPiece
ret
: ld b, a
ldh a, [hCurrentPiece]
ldh [hHeldPiece], a
ld a, b
ldh [hCurrentPiece], a
ld a, $FF
ldh [hSkipJingle], a
ret
ENDC ENDC

View File

@ -1,5 +1,5 @@
#Emulicious settings file #Emulicious settings file
#Wed Oct 18 13:09:20 CEST 2023 #Wed Oct 18 11:58:40 CEST 2023
WindowEventViewerWindowHeight=1416 WindowEventViewerWindowHeight=1416
WindowEventViewerWindowDivider=876 WindowEventViewerWindowDivider=876
WindowMemoryTracerWindowY=631 WindowMemoryTracerWindowY=631
@ -17,7 +17,7 @@ GameBoyErrorBreakpointEnabled20=false
StretchToWindow=false StretchToWindow=false
WindowTileViewerOpen=false WindowTileViewerOpen=false
DebuggerWestPanelSelectedTab=0 DebuggerWestPanelSelectedTab=0
WindowMemoryTracerWindowWidth=1136 WindowMemoryTracerWindowWidth=243
WindowPaletteViewerOpen=false WindowPaletteViewerOpen=false
Key37=-1 Key37=-1
Key36=-1 Key36=-1
@ -99,7 +99,7 @@ Gamepad1Key30=-1
BankSwapAtPCBreakpointEnabled=false BankSwapAtPCBreakpointEnabled=false
DebuggerMemorySelectedTab=HRAM DebuggerMemorySelectedTab=HRAM
WindowVideoViewerOpen=true WindowVideoViewerOpen=true
WindowMemoryEditorTabVisibleRect=0,0,583,128 WindowMemoryEditorTabVisibleRect=0,336,583,384
Gamepad1Key29=-1 Gamepad1Key29=-1
Gamepad1Key28=-1 Gamepad1Key28=-1
Gamepad1Key27=-1 Gamepad1Key27=-1
@ -136,7 +136,7 @@ Gamepad1Key13=-1
Gamepad1Key12=-1 Gamepad1Key12=-1
Gamepad1Key11=-1 Gamepad1Key11=-1
Gamepad1Key10=-1 Gamepad1Key10=-1
WindowMemoryEditorSelectedAddress=0 WindowMemoryEditorSelectedAddress=434
WindowMemoryEditorWidth=665 WindowMemoryEditorWidth=665
GameBoyErrorBreakpointCondition9= GameBoyErrorBreakpointCondition9=
GameBoyErrorBreakpointCondition8= GameBoyErrorBreakpointCondition8=
@ -155,7 +155,7 @@ Gamepad0Key35=-1
Gamepad0Key34=-1 Gamepad0Key34=-1
Gamepad0Key33=-1 Gamepad0Key33=-1
Gamepad0Key32=-1 Gamepad0Key32=-1
WindowMemoryEditorSelectedTab=HRAM WindowMemoryEditorSelectedTab=RAM
Gamepad0Key31=-1 Gamepad0Key31=-1
Gamepad0Key30=-1 Gamepad0Key30=-1
SMSGamepadAThreshold=50 SMSGamepadAThreshold=50
@ -178,8 +178,8 @@ Gamepad0Key20=-1
DebuggerSouthPanelSelectedTab=1 DebuggerSouthPanelSelectedTab=1
WindowEmuliciousWidth=816 WindowEmuliciousWidth=816
WindowVideoViewerWidth=980 WindowVideoViewerWidth=980
WindowMemoryEditorY=557 WindowMemoryEditorY=582
WindowMemoryEditorX=837 WindowMemoryEditorX=1506
Gamepad0Key19=-1 Gamepad0Key19=-1
Gamepad0Key18=-1 Gamepad0Key18=-1
Gamepad0Key17=-1 Gamepad0Key17=-1
@ -199,8 +199,8 @@ GameBoyErrorBreakpointMessage32=
InterruptBreakpointCondition= InterruptBreakpointCondition=
Recent0=C\:\\workspace\\dmgtris\\bin\\out.gb Recent0=C\:\\workspace\\dmgtris\\bin\\out.gb
GameBoyErrorBreakpointMessage20= GameBoyErrorBreakpointMessage20=
WindowEmuliciousY=474 WindowEmuliciousY=461
WindowEmuliciousX=1512 WindowEmuliciousX=1508
GameBoyErrorBreakpointEnabled9=false GameBoyErrorBreakpointEnabled9=false
GameBoyErrorBreakpointEnabled8=false GameBoyErrorBreakpointEnabled8=false
GameBoyErrorBreakpointEnabled7=false GameBoyErrorBreakpointEnabled7=false