Level selection

This commit is contained in:
Randy Thiemann 2023-10-21 16:31:26 +02:00
parent 8eba0dd290
commit d1468a8635
6 changed files with 315 additions and 139 deletions

View File

@ -73,166 +73,167 @@ sPieceYOffsets:: ; How to draw each piece. Y-offsets of the sprites.
db 0, 0, 7, 0 ; T
sSpeedCurve:: ; Speed curve of the game.
dw $0000 ; Level 0000
dw $0000, 0, $0100 ; Level 0000
db 1, 16 ; 1G every 16 frames
db 25, 14, 30, 40 ; ARE, DAS, LOCK, LINECLEAR
dw $0015 ; Level 0015
dw $0015, 15, $0100 ; Level 0015
db 1, 15 ; 1G every 15 frames
db 25, 14, 30, 40 ; ARE, DAS, LOCK, LINECLEAR
dw $0030 ; Level 0030
dw $0030, 30, $0100 ; Level 0030
db 1, 14 ; 1G every 14 frames
db 25, 14, 30, 40 ; ARE, DAS, LOCK, LINECLEAR
dw $0040 ; Level 0040
dw $0040, 40, $0100 ; Level 0040
db 1, 13 ; 1G every 13 frames
db 25, 14, 30, 40 ; ARE, DAS, LOCK, LINECLEAR
dw $0050 ; Level 0050
dw $0050, 50, $0100 ; Level 0050
db 1, 12 ; 1G every 12 frames
db 25, 14, 30, 40 ; ARE, DAS, LOCK, LINECLEAR
dw $0060 ; Level 0060
dw $0060, 60, $0100 ; Level 0060
db 1, 11 ; 1G every 11 frames
db 25, 14, 30, 40 ; ARE, DAS, LOCK, LINECLEAR
dw $0070 ; Level 0070
dw $0070, 70, $0100 ; Level 0070
db 1, 10 ; 1G every 10 frames
db 25, 14, 30, 40 ; ARE, DAS, LOCK, LINECLEAR
dw $0080 ; Level 0080
dw $0080, 80, $0100 ; Level 0080
db 1, 9 ; 1G every 9 frames
db 25, 14, 30, 40 ; ARE, DAS, LOCK, LINECLEAR
dw $0090 ; Level 0090
dw $0090, 90, $0100 ; Level 0090
db 1, 8 ; 1G every 8 frames
db 25, 14, 30, 40 ; ARE, DAS, LOCK, LINECLEAR
dw $0100 ; Level 0100
dw $0100, 100, $0200 ; Level 0100
db 1, 7 ; 1G every 7 frames
db 25, 14, 30, 40 ; ARE, DAS, LOCK, LINECLEAR
dw $0150 ; Level 0150
dw $0150, 150, $0200 ; Level 0150
db 1, 6 ; 1G every 6 frames
db 25, 14, 30, 40 ; ARE, DAS, LOCK, LINECLEAR
dw $0200 ; Level 0200
dw $0200, 200, $0300 ; Level 0200
db 1, 5 ; 1G every 5 frames
db 25, 14, 30, 40 ; ARE, DAS, LOCK, LINECLEAR
dw $0225 ; Level 0225
dw $0225, 225, $0300 ; Level 0225
db 1, 4 ; 1G every 4 frames
db 25, 14, 30, 40 ; ARE, DAS, LOCK, LINECLEAR
dw $0250 ; Level 0250
dw $0250, 250, $0300 ; Level 0250
db 1, 3 ; 1G every 3 frames
db 25, 14, 30, 40 ; ARE, DAS, LOCK, LINECLEAR
dw $0275 ; Level 0275
dw $0275, 275, $0300 ; Level 0275
db 1, 2 ; 1G every 2 frames
db 25, 14, 30, 40 ; ARE, DAS, LOCK, LINECLEAR
dw $0300 ; Level 0300
dw $0300, 300, $0400 ; Level 0300
db 1, 1 ; 1G
db 25, 14, 30, 32 ; ARE, DAS, LOCK, LINECLEAR
dw $0350 ; Level 0350
dw $0350, 350, $0350 ; Level 0350
db 2, 1 ; 2G
db 25, 14, 30, 32 ; ARE, DAS, LOCK, LINECLEAR
dw $0400 ; Level 0400
dw $0400, 400, $0400 ; Level 0400
db 3, 1 ; 3G
db 25, 14, 30, 32 ; ARE, DAS, LOCK, LINECLEAR
dw $0450 ; Level 0450
dw $0450, 450, $0500 ; Level 0450
db 4, 1 ; 4G
db 25, 14, 30, 32 ; ARE, DAS, LOCK, LINECLEAR
dw $0475 ; Level 0475
dw $0475, 475, $0500 ; Level 0475
db 5, 1 ; 5G
db 25, 14, 30, 32 ; ARE, DAS, LOCK, LINECLEAR
dw $0500 ; Level 0500
dw $0500, 500, $0600 ; Level 0500
db 20, 1 ; 20G
db 25, 14, 30, 24 ; ARE, DAS, LOCK, LINECLEAR
dw $0600 ; Level 0600
dw $0600, 600, $0700 ; Level 0600
db 20, 1 ; 20G
db 25, 8, 30, 24 ; ARE, DAS, LOCK, LINECLEAR
dw $0700 ; Level 0700
dw $0700, 700, $0800 ; Level 0700
db 20, 1 ; 20G
db 20, 8, 30, 24 ; ARE, DAS, LOCK, LINECLEAR
dw $0900 ; Level 0900
dw $0900, 900, $0900 ; Level 0900
db 20, 1 ; 20G
db 16, 6, 25, 16 ; ARE, DAS, LOCK, LINECLEAR
dw $1100 ; Level 1100
dw $1100, 1100, $1200 ; Level 1100
db 20, 1 ; 20G
db 12, 6, 25, 16 ; ARE, DAS, LOCK, LINECLEAR
dw $1200 ; Level 1200
dw $1200, 1200, $1300 ; Level 1200
db 20, 1 ; 20G
db 12, 6, 25, 8 ; ARE, DAS, LOCK, LINECLEAR
dw $1300 ; Level 1300
dw $1300, 1300, $1400 ; Level 1300
db 20, 1 ; 20G
db 10, 6, 20, 7 ; ARE, DAS, LOCK, LINECLEAR
dw $1400 ; Level 1400
dw $1400, 1400, $1500 ; Level 1400
db 20, 1 ; 20G
db 10, 6, 18, 6 ; ARE, DAS, LOCK, LINECLEAR
dw $1500 ; Level 1500
dw $1500, 1500, $1600 ; Level 1500
db 20, 1 ; 20G
db 8, 4, 16, 5 ; ARE, DAS, LOCK, LINECLEAR
dw $1600 ; Level 1600
dw $1600, 1600, $1700 ; Level 1600
db 20, 1 ; 20G
db 8, 4, 14, 4 ; ARE, DAS, LOCK, LINECLEAR
dw $1700 ; Level 1700
dw $1700, 1700, $1800 ; Level 1700
db 20, 1 ; 20G
db 6, 4, 12, 3 ; ARE, DAS, LOCK, LINECLEAR
dw $1800 ; Level 1800
dw $1800, 1800, $1900 ; Level 1800
db 20, 1 ; 20G
db 6, 4, 10, 3 ; ARE, DAS, LOCK, LINECLEAR
dw $1900 ; Level 1900
dw $1900, 1900, $2000 ; Level 1900
db 20, 1 ; 20G
db 4, 4, 8, 3 ; ARE, DAS, LOCK, LINECLEAR
dw $2000 ; Level 2000
dw $2000, 2000, $2100 ; Level 2000
db 20, 1 ; 20G
db 4, 3, 8, 3 ; ARE, DAS, LOCK, LINECLEAR
dw $2500 ; Level 2500
dw $2500, 2500, $2600 ; Level 2500
db 20, 1 ; 20G
db 2, 1, 8, 2 ; ARE, DAS, LOCK, LINECLEAR
dw $3000 ; Level 3000
dw $3000, 3000, $3100 ; Level 3000
db 20, 1 ; 20G
db 1, 1, 8, 1 ; ARE, DAS, LOCK, LINECLEAR
dw $4000 ; Level 4000
dw $4000, 4000, $4100 ; Level 4000
db 20, 1 ; 20G
db 1, 1, 6, 1 ; ARE, DAS, LOCK, LINECLEAR
dw $5000 ; Level 5000
dw $5000, 5000, $5100 ; Level 5000
db 20, 1 ; 20G
db 1, 1, 4, 1 ; ARE, DAS, LOCK, LINECLEAR
dw $6666 ; Level 6666
dw $6666, 6666, $6700 ; Level 6666
db 20, 1 ; 20G
db 1, 1, 2, 1 ; ARE, DAS, LOCK, LINECLEAR
dw $9999 ; Level 9999
dw $9999, 9999, $9999 ; Level 9999
db 20, 1 ; 20G
db 1, 1, 1, 1 ; ARE, DAS, LOCK, LINECLEAR
sSpeedCurveEnd::
dw $FFFF ; End.

View File

@ -93,6 +93,7 @@ DEF PALETTE_LIGHTER_2 EQU %01000000
DEF PALETTE_LIGHTER_3 EQU %00000000
DEF TITLE_A EQU $99ED
DEF TITLE_B EQU $99EF
DEF TITLE_LEVEL EQU $998C
DEF FIELD_TOP_LEFT EQU $9800+1
DEF TILE_FIELD_EMPTY EQU 4
DEF TILE_PIECE_0 EQU 10

View File

@ -20,6 +20,7 @@ hCurrentGravityPerTick:: ds 1
hCurrentFramesPerGravityTick:: ds 1
hNextSpeedUp:: ds 2
hSpeedCurvePtr:: ds 2
hStartSpeed:: ds 2
hRequiresLineClear:: ds 1
hLevel:: ds 2
@ -43,12 +44,58 @@ LevelInit::
ld [hl], a
ldh [hRequiresLineClear], a
ld hl, sSpeedCurve+2
ldh a, [hStartSpeed]
ld l, a
ldh a, [hStartSpeed+1]
ld h, a
; CLevel
ld a, [hl+]
ld b, a
and a, $0F
ld [wCLevel+3], a
ld a, b
swap a
and a, $0F
ld [wCLevel+2], a
ld a, [hl+]
ld b, a
and a, $0F
ld [wCLevel+1], a
ld a, b
swap a
and a, $0F
ld [wCLevel], a
ld a, l
ldh [hSpeedCurvePtr], a
ld a, h
ldh [hSpeedCurvePtr+1], a
; Binary level.
ld a, [hl+]
ldh [hLevel], a
ld a, [hl+]
ldh [hLevel+1], a
; NLevel
ld a, [hl+]
ld b, a
and a, $0F
ld [wNLevel+3], a
ld a, b
swap a
and a, $0F
ld [wNLevel+2], a
ld a, [hl+]
ld b, a
and a, $0F
ld [wNLevel+1], a
ld a, b
swap a
and a, $0F
ld [wNLevel], a
call DoSpeedUp
ret
@ -266,6 +313,12 @@ DoSpeedUp:
ldh a, [hSpeedCurvePtr+1]
ld h, a
; There's 4 bytes we don't care about.
inc hl
inc hl
inc hl
inc hl
; Get all the new data.
ld a, [hl+]
ldh [hCurrentGravityPerTick], a

View File

@ -43,6 +43,11 @@ Main::
; Zero out the ram where needed.
xor a, a
ldh [hSwapAB], a
ld hl, sSpeedCurve
ld a, l
ldh [hStartSpeed], a
ld a, h
ldh [hStartSpeed+1], a
call TimeInit
call IntrInit
call InputInit

View File

@ -75,18 +75,134 @@ TitleEventLoopHandler::
: ldh a, [hUpState]
cp a, 1
jr nz, :+
; TODO
jp IncrementLevel
jp EventLoopPostHandler
; Start level down?
: ldh a, [hDownState]
cp a, 1
jr nz, :+
; TODO
jp DecrementLevel
: jp EventLoopPostHandler
DecrementLevel:
; Decrement
ldh a, [hStartSpeed]
ld l, a
ldh a, [hStartSpeed+1]
ld h, a
ld bc, -12
add hl, bc
ld a, l
ldh [hStartSpeed], a
ld a, h
ldh [hStartSpeed+1], a
jp CheckLevelRange
IncrementLevel:
; Increment
ldh a, [hStartSpeed]
ld l, a
ldh a, [hStartSpeed+1]
ld h, a
ld bc, 12
add hl, bc
ld a, l
ldh [hStartSpeed], a
ld a, h
ldh [hStartSpeed+1], a
jp CheckLevelRange
CheckLevelRange:
; At end?
ld bc, sSpeedCurveEnd
ldh a, [hStartSpeed]
cp a, c
jr nz, .notatend
ldh a, [hStartSpeed+1]
cp a, b
jr nz, .notatend
ld hl, sSpeedCurve
ld a, l
ldh [hStartSpeed], a
ld a, h
ldh [hStartSpeed+1], a
.notatend
ld bc, sSpeedCurve-12
ldh a, [hStartSpeed]
cp a, c
jr nz, .notatstart
ldh a, [hStartSpeed+1]
cp a, b
jr nz, .notatstart
ld hl, sSpeedCurveEnd-12
ld a, l
ldh [hStartSpeed], a
ld a, h
ldh [hStartSpeed+1], a
.notatstart
jp EventLoopPostHandler
TitleVBlankHandler::
; Draw level.
ldh a, [hStartSpeed]
ld l, a
ldh a, [hStartSpeed+1]
ld h, a
ld a, [hl]
swap a
and a, $0F
ld b, a
ld a, TILE_0
add a, b
ld hl, TITLE_LEVEL+2
ld [hl], a
ldh a, [hStartSpeed]
ld l, a
ldh a, [hStartSpeed+1]
ld h, a
ld a, [hl]
and a, $0F
ld b, a
ld a, TILE_0
add a, b
ld hl, TITLE_LEVEL+3
ld [hl], a
ldh a, [hStartSpeed]
ld l, a
ldh a, [hStartSpeed+1]
ld h, a
inc hl
ld a, [hl]
swap a
and a, $0F
ld b, a
ld a, TILE_0
add a, b
ld hl, TITLE_LEVEL+0
ld [hl], a
ldh a, [hStartSpeed]
ld l, a
ldh a, [hStartSpeed+1]
ld h, a
inc hl
ld a, [hl]
and a, $0F
ld b, a
ld a, TILE_0
add a, b
ld hl, TITLE_LEVEL+1
ld [hl], a
; Draw A/B
ldh a, [hSwapAB]
cp a, 0
jr nz, :+

View File

@ -1,5 +1,5 @@
#Emulicious settings file
#Sat Oct 21 15:24:27 CEST 2023
#Sat Oct 21 16:30:35 CEST 2023
WindowProfilerWindowOpen=false
WindowEventViewerWindowHeight=1416
WindowEventViewerWindowDivider=876
@ -78,7 +78,7 @@ InterruptBreakpointEnabled=false
OutlineWidth=550
DebuggerEventFiltersGameBoy=
GameBoyErrorBreakpointSuspend9=true
WindowMemoryEditorOpen=false
WindowMemoryEditorOpen=true
GameBoyErrorBreakpointSuspend8=true
GameBoyErrorBreakpointSuspend7=true
WindowPaletteViewerY=619
@ -105,7 +105,7 @@ Gamepad1Key30=-1
BankSwapAtPCBreakpointEnabled=false
DebuggerMemorySelectedTab=HRAM
WindowVideoViewerOpen=true
WindowMemoryEditorTabVisibleRect=0,6096,583,384
WindowMemoryEditorTabVisibleRect=86,64,625,383
Gamepad1Key29=-1
Gamepad1Key28=-1
Gamepad1Key27=-1
@ -142,7 +142,7 @@ Gamepad1Key13=-1
Gamepad1Key12=-1
Gamepad1Key11=-1
Gamepad1Key10=-1
WindowMemoryEditorSelectedAddress=6144
WindowMemoryEditorSelectedAddress=68
WindowMemoryEditorWidth=665
GameBoyErrorBreakpointCondition9=
GameBoyErrorBreakpointCondition8=
@ -161,7 +161,7 @@ Gamepad0Key35=-1
Gamepad0Key34=-1
Gamepad0Key33=-1
Gamepad0Key32=-1
WindowMemoryEditorSelectedTab=VRAM
WindowMemoryEditorSelectedTab=ROM
Gamepad0Key31=-1
Gamepad0Key30=-1
SMSGamepadAThreshold=50
@ -182,10 +182,10 @@ Gamepad0Key21=-1
WindowDebuggerWidth=2576
Gamepad0Key20=-1
DebuggerSouthPanelSelectedTab=1
WindowEmuliciousWidth=816
WindowEmuliciousWidth=1096
WindowVideoViewerWidth=980
WindowMemoryEditorY=1009
WindowMemoryEditorX=2715
WindowMemoryEditorY=1374
WindowMemoryEditorX=799
Gamepad0Key19=-1
Gamepad0Key18=-1
Gamepad0Key17=-1
@ -199,15 +199,15 @@ Gamepad0Key11=-1
Gamepad0Key10=-1
StackWidth=2165
BankSwapAtPCBreakpointSuspend=true
WindowEmuliciousHeight=781
WindowEmuliciousHeight=1896
WindowSpriteViewerHeight=527
GameBoyErrorBreakpointMessage32=
InterruptBreakpointCondition=
Recent1=C\:\\workspace\\dmgtris\\bin\\out.gb
Recent0=K\:\\TGM\\dmgtris\\bin\\out.gb
GameBoyErrorBreakpointMessage20=
WindowEmuliciousY=509
WindowEmuliciousX=-1010
WindowEmuliciousY=-8
WindowEmuliciousX=-1088
GameBoyErrorBreakpointEnabled9=false
GameBoyErrorBreakpointEnabled8=false
GameBoyErrorBreakpointEnabled7=false
@ -287,8 +287,8 @@ SouthPanelHeight=1064
SMSbuttonsKeyboard=false
StackSplitLocation=534
WindowMemoryEditorHeight=534
GBGamepadKeyboard=false
WindowTilemapViewerWidth=404
GBGamepadKeyboard=false
UninitializedMemoryBreakpointCondition=
GameBoyErrorBreakpointSuspend19=true
GameBoyErrorBreakpointSuspend18=true
@ -299,6 +299,6 @@ GameBoyErrorBreakpointSuspend10=true
WindowSpriteViewerOpen=false
WindowProfilerWindowY=639
WindowProfilerWindowX=461
Scale=5.0
WindowProfilerWindowProcedureProfiler=true
Scale=6.75
KeyboardRequireWindowFocus=true
WindowProfilerWindowProcedureProfiler=true