Fix rotation bug.
This commit is contained in:
parent
fa73dc3a2b
commit
e96ec41e8b
|
@ -74,7 +74,7 @@ sPieceYOffsets:: ; How to draw each piece. Y-offsets of the sprites.
|
||||||
|
|
||||||
sSpeedCurve:: ; Speed curve of the game.
|
sSpeedCurve:: ; Speed curve of the game.
|
||||||
dw $0000 ; Level 0000
|
dw $0000 ; Level 0000
|
||||||
db 1, 16 ; 1G every 16 frames
|
db 1, 64 ; 1G every 16 frames
|
||||||
db 25, 14, 30, 40 ; ARE, DAS, LOCK, LINECLEAR
|
db 25, 14, 30, 40 ; ARE, DAS, LOCK, LINECLEAR
|
||||||
|
|
||||||
dw $0015 ; Level 0015
|
dw $0015 ; Level 0015
|
||||||
|
|
153
src/field.asm
153
src/field.asm
|
@ -343,6 +343,7 @@ CanPieceFit:
|
||||||
ENDR
|
ENDR
|
||||||
|
|
||||||
; Row 2
|
; Row 2
|
||||||
|
inc b
|
||||||
inc hl
|
inc hl
|
||||||
bit 3, [hl]
|
bit 3, [hl]
|
||||||
jr z, :+
|
jr z, :+
|
||||||
|
@ -381,6 +382,7 @@ CanPieceFit:
|
||||||
ENDR
|
ENDR
|
||||||
|
|
||||||
; Row 3
|
; Row 3
|
||||||
|
inc b
|
||||||
inc hl
|
inc hl
|
||||||
bit 3, [hl]
|
bit 3, [hl]
|
||||||
jr z, :+
|
jr z, :+
|
||||||
|
@ -418,6 +420,7 @@ CanPieceFit:
|
||||||
ENDR
|
ENDR
|
||||||
|
|
||||||
; Row 4
|
; Row 4
|
||||||
|
inc b
|
||||||
inc hl
|
inc hl
|
||||||
bit 3, [hl]
|
bit 3, [hl]
|
||||||
jr z, :+
|
jr z, :+
|
||||||
|
@ -723,38 +726,7 @@ FieldProcess::
|
||||||
ldh a, [hCurrentPieceRotationState]
|
ldh a, [hCurrentPieceRotationState]
|
||||||
ldh [hWantRotation], a
|
ldh [hWantRotation], a
|
||||||
|
|
||||||
|
; We check rotation first.
|
||||||
; Want left?
|
|
||||||
.wantleft
|
|
||||||
ldh a, [hLeftState]
|
|
||||||
cp a, 1
|
|
||||||
jr z, :+
|
|
||||||
ld b, a
|
|
||||||
ldh a, [hCurrentDAS]
|
|
||||||
ld c, a
|
|
||||||
ld a, b
|
|
||||||
cp a, c
|
|
||||||
jr c, .wantright
|
|
||||||
: ldh a, [hWantX]
|
|
||||||
dec a
|
|
||||||
ldh [hWantX], a
|
|
||||||
|
|
||||||
|
|
||||||
; Want right?
|
|
||||||
.wantright
|
|
||||||
ldh a, [hRightState]
|
|
||||||
cp a, 1
|
|
||||||
jr z, :+
|
|
||||||
ld b, a
|
|
||||||
ldh a, [hCurrentDAS]
|
|
||||||
ld c, a
|
|
||||||
ld a, b
|
|
||||||
cp a, c
|
|
||||||
jr c, .wantrotccw
|
|
||||||
: ldh a, [hWantX]
|
|
||||||
inc a
|
|
||||||
ldh [hWantX], a
|
|
||||||
|
|
||||||
; Want rotate CCW?
|
; Want rotate CCW?
|
||||||
.wantrotccw
|
.wantrotccw
|
||||||
ld a, [hSwapAB]
|
ld a, [hSwapAB]
|
||||||
|
@ -772,6 +744,7 @@ FieldProcess::
|
||||||
inc a
|
inc a
|
||||||
and a, $03
|
and a, $03
|
||||||
ldh [hWantRotation], a
|
ldh [hWantRotation], a
|
||||||
|
jr .tryrot
|
||||||
|
|
||||||
|
|
||||||
; Want rotate CW?
|
; Want rotate CW?
|
||||||
|
@ -786,46 +759,18 @@ FieldProcess::
|
||||||
ld a, [hAState]
|
ld a, [hAState]
|
||||||
.cp2
|
.cp2
|
||||||
cp a, 1
|
cp a, 1
|
||||||
jr nz, .moverotrequested
|
jp nz, .norot
|
||||||
ldh a, [hWantRotation]
|
ldh a, [hWantRotation]
|
||||||
dec a
|
dec a
|
||||||
and a, $03
|
and a, $03
|
||||||
ldh [hWantRotation], a
|
ldh [hWantRotation], a
|
||||||
|
|
||||||
|
|
||||||
; Do we need to try to move/rotate the piece?
|
; Try the rotation.
|
||||||
.moverotrequested
|
.tryrot
|
||||||
ldh a, [hWantRotation]
|
ldh a, [hCurrentPieceY]
|
||||||
ld b, a
|
|
||||||
ldh a, [hCurrentPieceRotationState]
|
|
||||||
cp a, b
|
|
||||||
jr nz, .trymoverot ; Move and rotate.
|
|
||||||
ldh a, [hWantX]
|
|
||||||
ld b, a
|
ld b, a
|
||||||
ldh a, [hCurrentPieceX]
|
ldh a, [hCurrentPieceX]
|
||||||
cp a, b
|
|
||||||
jp z, .postmove ; Neither move nor rotate.
|
|
||||||
|
|
||||||
; Move only.
|
|
||||||
ldh a, [hCurrentPieceY]
|
|
||||||
ld b, a
|
|
||||||
ldh a, [hWantX]
|
|
||||||
call XYToSFieldPtr
|
|
||||||
ld d, h
|
|
||||||
ld e, l
|
|
||||||
call GetPieceData
|
|
||||||
call CanPieceFit
|
|
||||||
cp a, $FF
|
|
||||||
jp nz, .postmove
|
|
||||||
ldh a, [hWantX]
|
|
||||||
ldh [hCurrentPieceX], a
|
|
||||||
jp .postmove
|
|
||||||
|
|
||||||
|
|
||||||
.trymoverot
|
|
||||||
ldh a, [hCurrentPieceY]
|
|
||||||
ld b, a
|
|
||||||
ldh a, [hWantX]
|
|
||||||
call XYToSFieldPtr
|
call XYToSFieldPtr
|
||||||
ld d, h
|
ld d, h
|
||||||
ld e, l
|
ld e, l
|
||||||
|
@ -845,12 +790,10 @@ FieldProcess::
|
||||||
call CanPieceFit
|
call CanPieceFit
|
||||||
cp a, $FF
|
cp a, $FF
|
||||||
jr nz, .maybekick
|
jr nz, .maybekick
|
||||||
ldh a, [hWantX]
|
|
||||||
ldh [hCurrentPieceX], a
|
|
||||||
ldh a, [hWantRotation]
|
ldh a, [hWantRotation]
|
||||||
ldh [hCurrentPieceRotationState], a
|
ldh [hCurrentPieceRotationState], a
|
||||||
call SetPieceDataOffset
|
call SetPieceDataOffset
|
||||||
jp .postmove
|
jp .norot
|
||||||
|
|
||||||
|
|
||||||
; Try kicks if the piece isn't I or O. And in the case of J L and T, only if the blocked side is the left or right.
|
; Try kicks if the piece isn't I or O. And in the case of J L and T, only if the blocked side is the left or right.
|
||||||
|
@ -858,26 +801,26 @@ FieldProcess::
|
||||||
ld c, a
|
ld c, a
|
||||||
ldh a, [hCurrentPiece]
|
ldh a, [hCurrentPiece]
|
||||||
cp a, PIECE_I
|
cp a, PIECE_I
|
||||||
jr z, .postmove
|
jr z, .norot
|
||||||
cp a, PIECE_O
|
cp a, PIECE_O
|
||||||
jr z, .postmove
|
jr z, .norot
|
||||||
cp a, PIECE_S
|
cp a, PIECE_S
|
||||||
jr z, .trykickright
|
jr z, .trykickright
|
||||||
cp a, PIECE_Z
|
cp a, PIECE_Z
|
||||||
jr z, .trykickright
|
jr z, .trykickright
|
||||||
ld a, c
|
ld a, c
|
||||||
cp a, 1
|
cp a, 1
|
||||||
jr z, .postmove
|
jr z, .norot
|
||||||
cp a, 5
|
cp a, 5
|
||||||
jr z, .postmove
|
jr z, .norot
|
||||||
cp a, 9
|
cp a, 9
|
||||||
jr z, .postmove
|
jr z, .norot
|
||||||
|
|
||||||
|
|
||||||
|
; A step to the right.
|
||||||
.trykickright
|
.trykickright
|
||||||
ldh a, [hCurrentPieceY]
|
ldh a, [hCurrentPieceY]
|
||||||
ld b, a
|
ld b, a
|
||||||
ldh a, [hWantX]
|
ldh a, [hCurrentPieceX]
|
||||||
inc a
|
inc a
|
||||||
call XYToSFieldPtr
|
call XYToSFieldPtr
|
||||||
ld d, h
|
ld d, h
|
||||||
|
@ -898,19 +841,20 @@ FieldProcess::
|
||||||
call CanPieceFit
|
call CanPieceFit
|
||||||
cp a, $FF
|
cp a, $FF
|
||||||
jr nz, .trykickleft
|
jr nz, .trykickleft
|
||||||
ldh a, [hWantX]
|
ldh a, [hCurrentPieceX]
|
||||||
inc a
|
inc a
|
||||||
ldh [hCurrentPieceX], a
|
ldh [hCurrentPieceX], a
|
||||||
ldh a, [hWantRotation]
|
ldh a, [hWantRotation]
|
||||||
ldh [hCurrentPieceRotationState], a
|
ldh [hCurrentPieceRotationState], a
|
||||||
call SetPieceDataOffset
|
call SetPieceDataOffset
|
||||||
jr .postmove
|
jr .norot
|
||||||
|
|
||||||
|
|
||||||
|
; And a step to the left.
|
||||||
.trykickleft
|
.trykickleft
|
||||||
ldh a, [hCurrentPieceY]
|
ldh a, [hCurrentPieceY]
|
||||||
ld b, a
|
ld b, a
|
||||||
ldh a, [hWantX]
|
ldh a, [hCurrentPieceX]
|
||||||
dec a
|
dec a
|
||||||
call XYToSFieldPtr
|
call XYToSFieldPtr
|
||||||
ld d, h
|
ld d, h
|
||||||
|
@ -930,8 +874,8 @@ FieldProcess::
|
||||||
pop bc
|
pop bc
|
||||||
call CanPieceFit
|
call CanPieceFit
|
||||||
cp a, $FF
|
cp a, $FF
|
||||||
jr nz, .postmove
|
jr nz, .norot
|
||||||
ldh a, [hWantX]
|
ldh a, [hCurrentPieceX]
|
||||||
dec a
|
dec a
|
||||||
ldh [hCurrentPieceX], a
|
ldh [hCurrentPieceX], a
|
||||||
ldh a, [hWantRotation]
|
ldh a, [hWantRotation]
|
||||||
|
@ -939,8 +883,57 @@ FieldProcess::
|
||||||
call SetPieceDataOffset
|
call SetPieceDataOffset
|
||||||
|
|
||||||
|
|
||||||
.postmove
|
; Do we want to move left?
|
||||||
|
.norot
|
||||||
|
ldh a, [hLeftState]
|
||||||
|
cp a, 1
|
||||||
|
jr z, :+
|
||||||
|
ld b, a
|
||||||
|
ldh a, [hCurrentDAS]
|
||||||
|
ld c, a
|
||||||
|
ld a, b
|
||||||
|
cp a, c
|
||||||
|
jr c, .wantright
|
||||||
|
: ldh a, [hWantX]
|
||||||
|
dec a
|
||||||
|
ldh [hWantX], a
|
||||||
|
jr .trymove
|
||||||
|
|
||||||
|
|
||||||
|
; Want right?
|
||||||
|
.wantright
|
||||||
|
ldh a, [hRightState]
|
||||||
|
cp a, 1
|
||||||
|
jr z, :+
|
||||||
|
ld b, a
|
||||||
|
ldh a, [hCurrentDAS]
|
||||||
|
ld c, a
|
||||||
|
ld a, b
|
||||||
|
cp a, c
|
||||||
|
jr c, .donemanipulating
|
||||||
|
: ldh a, [hWantX]
|
||||||
|
inc a
|
||||||
|
ldh [hWantX], a
|
||||||
|
|
||||||
|
|
||||||
|
; Try the movement.
|
||||||
|
.trymove
|
||||||
|
ldh a, [hCurrentPieceY]
|
||||||
|
ld b, a
|
||||||
|
ldh a, [hWantX]
|
||||||
|
call XYToSFieldPtr
|
||||||
|
ld d, h
|
||||||
|
ld e, l
|
||||||
|
call GetPieceData
|
||||||
|
call CanPieceFit
|
||||||
|
cp a, $FF
|
||||||
|
jr nz, .donemanipulating
|
||||||
|
ldh a, [hWantX]
|
||||||
|
ldh [hCurrentPieceX], a
|
||||||
|
|
||||||
|
|
||||||
; Are we grounded?
|
; Are we grounded?
|
||||||
|
.donemanipulating
|
||||||
ldh a, [hCurrentPieceY]
|
ldh a, [hCurrentPieceY]
|
||||||
inc a
|
inc a
|
||||||
ld b, a
|
ld b, a
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#Emulicious settings file
|
#Emulicious settings file
|
||||||
#Sat Oct 21 14:31:03 CEST 2023
|
#Sat Oct 21 15:08:21 CEST 2023
|
||||||
WindowProfilerWindowOpen=false
|
WindowProfilerWindowOpen=false
|
||||||
WindowEventViewerWindowHeight=1416
|
WindowEventViewerWindowHeight=1416
|
||||||
WindowEventViewerWindowDivider=876
|
WindowEventViewerWindowDivider=876
|
||||||
|
@ -7,7 +7,7 @@ WindowMemoryTracerWindowY=631
|
||||||
WindowMemoryTracerWindowX=383
|
WindowMemoryTracerWindowX=383
|
||||||
Update=2
|
Update=2
|
||||||
AudioSync=false
|
AudioSync=false
|
||||||
DebuggerMemoryTabVisibleRect=0,0,0,0
|
DebuggerMemoryTabVisibleRect=0,0,687,128
|
||||||
WindowProfilerWindowWidth=1073
|
WindowProfilerWindowWidth=1073
|
||||||
UninitializedMemoryBreakpointSuspend=true
|
UninitializedMemoryBreakpointSuspend=true
|
||||||
GameBoyErrorBreakpointEnabled32=false
|
GameBoyErrorBreakpointEnabled32=false
|
||||||
|
@ -92,7 +92,7 @@ GameBoyErrorBreakpointSuspend2=true
|
||||||
GameBoyErrorBreakpointSuspend1=true
|
GameBoyErrorBreakpointSuspend1=true
|
||||||
GameBoyErrorBreakpointSuspend0=true
|
GameBoyErrorBreakpointSuspend0=true
|
||||||
DebuggerConsoleLogBreakpoints=true
|
DebuggerConsoleLogBreakpoints=true
|
||||||
WindowDebuggerOpen=false
|
WindowDebuggerOpen=true
|
||||||
Gamepad1Key37=-1
|
Gamepad1Key37=-1
|
||||||
Gamepad1Key36=-1
|
Gamepad1Key36=-1
|
||||||
Gamepad1Key35=-1
|
Gamepad1Key35=-1
|
||||||
|
@ -287,8 +287,8 @@ SouthPanelHeight=1064
|
||||||
SMSbuttonsKeyboard=false
|
SMSbuttonsKeyboard=false
|
||||||
StackSplitLocation=534
|
StackSplitLocation=534
|
||||||
WindowMemoryEditorHeight=534
|
WindowMemoryEditorHeight=534
|
||||||
WindowTilemapViewerWidth=404
|
|
||||||
GBGamepadKeyboard=false
|
GBGamepadKeyboard=false
|
||||||
|
WindowTilemapViewerWidth=404
|
||||||
UninitializedMemoryBreakpointCondition=
|
UninitializedMemoryBreakpointCondition=
|
||||||
GameBoyErrorBreakpointSuspend19=true
|
GameBoyErrorBreakpointSuspend19=true
|
||||||
GameBoyErrorBreakpointSuspend18=true
|
GameBoyErrorBreakpointSuspend18=true
|
||||||
|
@ -300,5 +300,5 @@ WindowSpriteViewerOpen=false
|
||||||
WindowProfilerWindowY=639
|
WindowProfilerWindowY=639
|
||||||
WindowProfilerWindowX=461
|
WindowProfilerWindowX=461
|
||||||
Scale=5.0
|
Scale=5.0
|
||||||
KeyboardRequireWindowFocus=true
|
|
||||||
WindowProfilerWindowProcedureProfiler=true
|
WindowProfilerWindowProcedureProfiler=true
|
||||||
|
KeyboardRequireWindowFocus=true
|
||||||
|
|
Loading…
Reference in New Issue