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
wField:: ds (10*24)
wShadowField:: ds (14*26)
wField:: ds (10*21)
SECTION "Field Functions", ROM0
FieldInit::
ld hl, wField
ld bc, 10*24
ld bc, 10*21
ld d, 1
call UnsafeMemSet
ld hl, wShadowField
ld bc, 14*26
ld d, $FF
call UnsafeMemSet
ret
FieldClear::
ld hl, wField
ld bc, 10*24
ld bc, 10*21
ld d, TILE_FIELD_EMPTY
call UnsafeMemSet
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.
BlitField::
; What to copy
ld de, wField + 40
ld de, wField + 10
; Where to put it
ld hl, FIELD_TOP_LEFT
; How much to increment hl after each row

View File

@ -22,8 +22,6 @@ hCurrentPieceX: ds 1
hCurrentPieceY: ds 1
hCurrentPieceRotationState: ds 1
hHeldPiece: ds 1
hHoldSpent: ds 1
hSkipJingle: ds 1
SECTION "Gameplay Functions", ROM0
@ -64,8 +62,6 @@ SwitchToGameplay::
; We don't start with a held piece.
ld a, PIECE_NONE
ldh [hHeldPiece], a
xor a, a
ldh [hHoldSpent], a
; Leady mode.
ld a, MODE_LEADY
@ -100,8 +96,7 @@ GamePlayEventLoopHandler::
cp MODE_FETCH_PIECE
jr z, fetchPieceMode
cp MODE_SPAWN_PIECE
jp z, spawnPieceMode
jr z, spawnPieceMode
; Draw "READY" and wait a bit.
leadyMode:
@ -118,7 +113,6 @@ leadyMode:
call UnsafeMemCopy
jp drawStaticInfo
; Draw "GO" and wait a bit.
goMode:
ld a, [wModeCounter]
@ -134,7 +128,6 @@ goMode:
call UnsafeMemCopy
jp drawStaticInfo
; Clear the field, ready for gameplay.
postGoMode:
ld a, MODE_FETCH_PIECE
@ -142,74 +135,31 @@ postGoMode:
call FieldClear
jp drawStaticInfo
; Fetch the next piece.
fetchPieceMode:
ld a, [wNextPiece]
ldh [hCurrentPiece], a
call GetNextPiece
; A piece will spawn in the middle, at the top of the screen, not rotated by default.
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
; Check if IRS is charged.
ld a, [hAState]
cp a, 0
jr z, .checkIRSB
ld a, 1
ldh [hCurrentPieceRotationState], a
ld a, SFX_IRS
call SFXEnqueue
.checkIRSB
ld b, a
ld a, [hBState]
cp a, 0
jr z, .checkJingle
ld a, 3
ldh [hCurrentPieceRotationState], a
or a, b
jr z, :+
ld a, SFX_IRS
call SFXEnqueue
.checkJingle
ld a, [hSkipJingle]
cp a, 0
jr nz, .skipJingle
.playNextJingle
ld a, [wNextPiece]
: ld a, [wNextPiece]
call SFXEnqueue
.skipJingle
ld a, MODE_SPAWN_PIECE
ld [wMode], a
; State falls through to the next.
jp drawStaticInfo
; Spawn the piece.
spawnPieceMode:
; TODO: At this point all the info needed to spawn the piece is known.
; 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.
; todo
call ToShadowField
call FromShadowField
ld a, [hEvenFrame]
cp a, 0
@ -226,7 +176,7 @@ spawnPieceMode:
jr nz, :+
ld a, MODE_FETCH_PIECE
ld [wMode], a
jr drawStaticInfo
jp drawStaticInfo
: ld a, [hLeftState]
cp a, 1
@ -238,20 +188,14 @@ spawnPieceMode:
jr z, :++
cp a, 12
jr nc, :+
jr drawStaticInfo
jp drawStaticInfo
: ldh a, [hFrameCtr]
and %00000111
cp 4
jr nz, drawStaticInfo
jp nz, drawStaticInfo
: ld a, SFX_MOVE
call SFXEnqueue
jr 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.
jp drawStaticInfo
; Always draw the score, level, next piece, and held piece.
@ -277,56 +221,4 @@ drawStaticInfo:
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

View File

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