diff --git a/bin/DMGTRIS.GBC b/bin/DMGTRIS.GBC index b2b3407..d0fe480 100644 Binary files a/bin/DMGTRIS.GBC and b/bin/DMGTRIS.GBC differ diff --git a/bin/DMGTRIS.pocket b/bin/DMGTRIS.pocket index a96f92c..ed1d364 100644 Binary files a/bin/DMGTRIS.pocket and b/bin/DMGTRIS.pocket differ diff --git a/src/field.asm b/src/field.asm index db30d20..dc63a97 100644 --- a/src/field.asm +++ b/src/field.asm @@ -582,13 +582,69 @@ TrySpawnPiece:: cp a, $FF ret z - ; Otherwise check the rotation, and if it's not zero, try to reset it. + ; Otherwise, try in this order: 0, 1, 3, 2 ldh a, [hCurrentPieceRotationState] + ldh [hWantRotation], a + + ; Try rotation state 0. +.try0 cp a, 0 + jr z, .try1 + xor a, a + ldh [hCurrentPieceRotationState], a + call SetPieceDataOffset + ldh a, [hCurrentPieceY] + ld b, a + ldh a, [hCurrentPieceX] + call XYToSFieldPtr + ld d, h + ld e, l + call GetPieceDataFast + call CanPieceFitFast + cp a, $FF ret z - ; Reset the rotation. - xor a, a + ; Try rotation state 1. +.try1 + ldh a, [hWantRotation] + cp a, 1 + jr z, .try3 + ld a, 1 + ldh [hCurrentPieceRotationState], a + call SetPieceDataOffset + ldh a, [hCurrentPieceY] + ld b, a + ldh a, [hCurrentPieceX] + call XYToSFieldPtr + ld d, h + ld e, l + call GetPieceDataFast + call CanPieceFitFast + cp a, $FF + ret z + + ; Try rotation state 3. +.try3 + ldh a, [hWantRotation] + cp a, 3 + jr z, .try2 + ld a, 3 + ldh [hCurrentPieceRotationState], a + call SetPieceDataOffset + ldh a, [hCurrentPieceY] + ld b, a + ldh a, [hCurrentPieceX] + call XYToSFieldPtr + ld d, h + ld e, l + call GetPieceDataFast + call CanPieceFitFast + cp a, $FF + ret z + + ; Try rotation state 2. +.try2 + ld a, 2 ldh [hCurrentPieceRotationState], a call SetPieceDataOffset ldh a, [hCurrentPieceY]