Compare commits

..

No commits in common. "9cedde3ed7abc7e5b09be72b2334e231e7defda7" and "eab34d8f0b66eb2b965fb7f00d6cf56836d1a454" have entirely different histories.

11 changed files with 227 additions and 632 deletions

View File

@ -1,4 +1,8 @@
SECTION "Cartridge Header", ROM0[$100] ; *****************************************************************************
nop ; * *
jp Main ; * Cartridge Header. *
ds $150 - @, 0 ; * *
; *****************************************************************************
SECTION "Header", ROM0[$100]
jp MainEntryPoint
ds $150 - @, 0 ; RGBFIX will fill in the header.

View File

@ -1,358 +0,0 @@
IF !DEF(CONSTANTS_ASM)
DEF CONSTANTS_ASM EQU 1
SECTION "Static Data", ROM0
sPieceXOffsets:: ; How to draw each piece. X-offsets of the sprites.
db 0, 8, 16, 24 ; I
db 0, 8, 8, 16 ; Z
db 0, 8, 8, 16 ; S
db 0, 8, 16, 16 ; J
db 0, 0, 8, 16 ; L
db 8, 8, 16, 16 ; O
db 0, 8, 8, 16 ; T
sPieceYOffsets:: ; How to draw each piece. Y-offsets of the sprites.
db 0, 0, 0, 0 ; I
db 0, 0, 7, 7 ; Z
db 7, 7, 0, 0 ; S
db 0, 0, 0, 7 ; J
db 7, 0, 0, 0 ; L
db 0, 7, 0, 7 ; O
db 0, 0, 7, 0 ; T
sSpeedCurve:: ; Speed curve of the game.
dw $0000 ; Level 0000
db 0, %00000001 ; 1/8G
db 25, 14, 30, 40 ; ARE, DAS, LOCK, LINECLEAR
dw $0100 ; Level 0100
db 0, %00010001 ; 2/8G
db 25, 14, 30, 40 ; ARE, DAS, LOCK, LINECLEAR
dw $0150 ; Level 0150
db 0, %01001001 ; 3/8G
db 25, 14, 30, 40 ; ARE, DAS, LOCK, LINECLEAR
dw $0200 ; Level 0200
db 0, %01010101 ; 4/8G
db 25, 14, 30, 40 ; ARE, DAS, LOCK, LINECLEAR
dw $0225 ; Level 0225
db 0, %01011101 ; 5/8G
db 25, 14, 30, 40 ; ARE, DAS, LOCK, LINECLEAR
dw $0250 ; Level 0250
db 0, %01110111 ; 6/8G
db 25, 14, 30, 40 ; ARE, DAS, LOCK, LINECLEAR
dw $0275 ; Level 0275
db 0, %01111111 ; 7/8G
db 25, 14, 30, 40 ; ARE, DAS, LOCK, LINECLEAR
dw $0300 ; Level 0300
db 1, %11111111 ; 1G
db 25, 14, 30, 32 ; ARE, DAS, LOCK, LINECLEAR
dw $0350 ; Level 0350
db 2, %11111111 ; 2G
db 25, 14, 30, 32 ; ARE, DAS, LOCK, LINECLEAR
dw $0400 ; Level 0400
db 3, %11111111 ; 3G
db 25, 14, 30, 32 ; ARE, DAS, LOCK, LINECLEAR
dw $0450 ; Level 0450
db 4, %11111111 ; 4G
db 25, 14, 30, 32 ; ARE, DAS, LOCK, LINECLEAR
dw $0475 ; Level 0475
db 5, %11111111 ; 5G
db 25, 14, 30, 32 ; ARE, DAS, LOCK, LINECLEAR
dw $0500 ; Level 0500
db 20, %11111111 ; 20G
db 25, 14, 30, 24 ; ARE, DAS, LOCK, LINECLEAR
dw $0600 ; Level 0600
db 20, %11111111 ; 20G
db 25, 8, 30, 24 ; ARE, DAS, LOCK, LINECLEAR
dw $0700 ; Level 0700
db 20, %11111111 ; 20G
db 20, 8, 30, 24 ; ARE, DAS, LOCK, LINECLEAR
dw $0900 ; Level 0900
db 20, %11111111 ; 20G
db 16, 6, 25, 16 ; ARE, DAS, LOCK, LINECLEAR
dw $1100 ; Level 1100
db 20, %11111111 ; 20G
db 12, 6, 25, 16 ; ARE, DAS, LOCK, LINECLEAR
dw $1200 ; Level 1200
db 20, %11111111 ; 20G
db 12, 6, 25, 8 ; ARE, DAS, LOCK, LINECLEAR
dw $1300 ; Level 1300
db 20, %11111111 ; 20G
db 10, 6, 20, 7 ; ARE, DAS, LOCK, LINECLEAR
dw $1400 ; Level 1400
db 20, %11111111 ; 20G
db 10, 6, 18, 6 ; ARE, DAS, LOCK, LINECLEAR
dw $1500 ; Level 1500
db 20, %11111111 ; 20G
db 8, 4, 16, 5 ; ARE, DAS, LOCK, LINECLEAR
dw $1600 ; Level 1600
db 20, %11111111 ; 20G
db 8, 4, 14, 4 ; ARE, DAS, LOCK, LINECLEAR
dw $1700 ; Level 1700
db 20, %11111111 ; 20G
db 6, 4, 12, 3 ; ARE, DAS, LOCK, LINECLEAR
dw $1800 ; Level 1800
db 20, %11111111 ; 20G
db 6, 4, 10, 3 ; ARE, DAS, LOCK, LINECLEAR
dw $1900 ; Level 1900
db 20, %11111111 ; 20G
db 4, 4, 8, 3 ; ARE, DAS, LOCK, LINECLEAR
dw $2000 ; Level 2000
db 20, %11111111 ; 20G
db 4, 3, 8, 3 ; ARE, DAS, LOCK, LINECLEAR
dw $2500 ; Level 2500
db 20, %11111111 ; 20G
db 2, 1, 8, 2 ; ARE, DAS, LOCK, LINECLEAR
dw $3000 ; Level 3000
db 20, %11111111 ; 20G
db 1, 1, 8, 1 ; ARE, DAS, LOCK, LINECLEAR
dw $4000 ; Level 4000
db 20, %11111111 ; 20G
db 1, 1, 6, 1 ; ARE, DAS, LOCK, LINECLEAR
dw $5000 ; Level 5000
db 20, %11111111 ; 20G
db 1, 1, 4, 1 ; ARE, DAS, LOCK, LINECLEAR
dw $6666 ; Level 6666
db 20, %11111111 ; 20G
db 1, 1, 2, 1 ; ARE, DAS, LOCK, LINECLEAR
dw $9999 ; Level 9999
db 20, %11111111 ; 20G
db 1, 1, 1, 1 ; ARE, DAS, LOCK, LINECLEAR
sPieceRotationStates:: ; How each piece is rotated.
; I
db %0000
db %1111
db %0000
db %0000
db %0010
db %0010
db %0010
db %0010
db %0000
db %1111
db %0000
db %0000
db %0010
db %0010
db %0010
db %0010
; Z
db %0000
db %1100
db %0110
db %0000
db %0010
db %0110
db %0100
db %0000
db %0000
db %1100
db %0110
db %0000
db %0010
db %0110
db %0100
db %0000
; S
db %0000
db %0110
db %1100
db %0000
db %1000
db %1100
db %0100
db %0000
db %0000
db %0110
db %1100
db %0000
db %1000
db %1100
db %0100
db %0000
; J
db %0000
db %1110
db %0010
db %0000
db %0110
db %0100
db %0100
db %0000
db %0000
db %1000
db %1110
db %0000
db %0100
db %0100
db %1100
db %0000
; L
db %0000
db %1110
db %1000
db %0000
db %0100
db %0100
db %0110
db %0000
db %0000
db %0010
db %1110
db %0000
db %1100
db %0100
db %0100
db %0000
; O
db %0000
db %0110
db %0110
db %0000
db %0000
db %0110
db %0110
db %0000
db %0000
db %0110
db %0110
db %0000
db %0000
db %0110
db %0110
db %0000
; T
db %0000
db %1110
db %0100
db %0000
db %0100
db %0110
db %0100
db %0000
db %0000
db %0100
db %1110
db %0000
db %0100
db %1100
db %0100
db %0000
DEF PALETTE_REGULAR EQU %11100100
DEF PALETTE_INVERTED EQU %00011011
DEF PALETTE_MONO_0 EQU %11111111
DEF PALETTE_MONO_1 EQU %10101010
DEF PALETTE_MONO_2 EQU %01010101
DEF PALETTE_MONO_3 EQU %00000000
DEF PALETTE_DARKER_0 EQU %11100100
DEF PALETTE_DARKER_1 EQU %11111001
DEF PALETTE_DARKER_2 EQU %11111110
DEF PALETTE_DARKER_3 EQU %11111111
DEF PALETTE_LIGHTER_0 EQU %11100100
DEF PALETTE_LIGHTER_1 EQU %10010000
DEF PALETTE_LIGHTER_2 EQU %01000000
DEF PALETTE_LIGHTER_3 EQU %00000000
DEF FIELD_TOP_LEFT EQU $9800+(0*32)+1
DEF FIELD_ROW_1 EQU $9800+(0*32)+1
DEF FIELD_ROW_2 EQU $9800+(1*32)+1
DEF FIELD_ROW_3 EQU $9800+(2*32)+1
DEF FIELD_ROW_4 EQU $9800+(3*32)+1
DEF FIELD_ROW_5 EQU $9800+(4*32)+1
DEF FIELD_ROW_6 EQU $9800+(5*32)+1
DEF FIELD_ROW_7 EQU $9800+(6*32)+1
DEF FIELD_ROW_8 EQU $9800+(7*32)+1
DEF FIELD_ROW_9 EQU $9800+(8*32)+1
DEF FIELD_ROW_10 EQU $9800+(9*32)+1
DEF FIELD_ROW_11 EQU $9800+(10*32)+1
DEF FIELD_ROW_12 EQU $9800+(11*32)+1
DEF FIELD_ROW_13 EQU $9800+(12*32)+1
DEF FIELD_ROW_14 EQU $9800+(13*32)+1
DEF FIELD_ROW_15 EQU $9800+(14*32)+1
DEF FIELD_ROW_16 EQU $9800+(15*32)+1
DEF FIELD_ROW_17 EQU $9800+(16*32)+1
DEF FIELD_ROW_18 EQU $9800+(17*32)+1
DEF FIELD_ROW_19 EQU $9800+(18*32)+1
DEF FIELD_ROW_20 EQU $9800+(19*32)+1
DEF TILE_FIELD_EMPTY EQU 7
DEF TILE_PIECE_0 EQU 10
DEF TILE_0 EQU 110
DEF NEXT_BASE_X EQU 120
DEF NEXT_BASE_Y EQU 40
DEF HOLD_BASE_X EQU 120
DEF HOLD_BASE_Y EQU 80
DEF DIGIT_BASE_X EQU 112
DEF SCORE_BASE_Y EQU 115
DEF CLEVEL_BASE_Y EQU 136
DEF NLEVEL_BASE_Y EQU 148
DEF SCURVE_N_ENTRIES EQU 32
DEF SCURVE_ENTRY_SIZE EQU 8
DEF PIECE_I EQU 0
DEF PIECE_Z EQU 1
DEF PIECE_S EQU 2
DEF PIECE_J EQU 3
DEF PIECE_L EQU 4
DEF PIECE_O EQU 5
DEF PIECE_T EQU 6
ENDC

View File

@ -1,25 +1,110 @@
IF !DEF(GLOBALS_ASM) ; *****************************************************************************
DEF GLOBALS_ASM EQU 1 ; * *
; * Libraries and Defines *
; * *
; *****************************************************************************
INCLUDE "vendor/hardware.inc" INCLUDE "vendor/hardware.inc"
INCLUDE "vendor/structs.asm" INCLUDE "vendor/structs.asm"
INCLUDE "constants.asm"
; *****************************************************************************
; * *
; * Game Variables *
; * *
; *****************************************************************************
SECTION "General Game Variables", WRAM0 SECTION "General Game Variables", WRAM0
wLCDCCtr:: db wLCDCCtr:: db
wEvenFrame:: db wEvenFrame:: db
wField:: ds (10*22) wField:: ds (10*22)
wRNGSeed:: ds 4
SECTION "Important Game Variables", HRAM SECTION "Important Game Variables", HRAM
hCtr:: ds 1 hScore:: ds 6
hScore:: ds 6
hCLevel:: ds 6 hCLevel:: ds 6
hNLevel:: ds 6 hNLevel:: ds 6
; *****************************************************************************
; * *
; * Static Data *
; * *
; *****************************************************************************
SECTION "Static Data", ROM0
sPieceXOffsets::
db 0, 8, 16, 24 ; I
db 0, 8, 8, 16 ; Z
db 0, 8, 8, 16 ; S
db 0, 8, 16, 16 ; J
db 0, 0, 8, 16 ; L
db 8, 8, 16, 16 ; O
db 0, 8, 8, 16 ; T
sPieceYOffsets::
db 0, 0, 0, 0 ; I
db 0, 0, 7, 7 ; Z
db 7, 7, 0, 0 ; S
db 0, 0, 0, 7 ; J
db 0, 7, 0, 0 ; L
db 0, 7, 0, 7 ; O
db 0, 0, 7, 0 ; T
; *****************************************************************************
; * *
; * Convenience Defines *
; * *
; *****************************************************************************
DEF PALETTE_REGULAR EQU %11100100
DEF PALETTE_INVERTED EQU %00011011
DEF PALETTE_MONO_0 EQU %11111111
DEF PALETTE_MONO_1 EQU %10101010
DEF PALETTE_MONO_2 EQU %01010101
DEF PALETTE_MONO_3 EQU %00000000
DEF PALETTE_DARKER_0 EQU %11100100
DEF PALETTE_DARKER_1 EQU %11111001
DEF PALETTE_DARKER_2 EQU %11111110
DEF PALETTE_DARKER_3 EQU %11111111
DEF PALETTE_LIGHTER_0 EQU %11100100
DEF PALETTE_LIGHTER_1 EQU %10010000
DEF PALETTE_LIGHTER_2 EQU %01000000
DEF PALETTE_LIGHTER_3 EQU %00000000
DEF FIELD_TOP_LEFT EQU $9800+(0*32)+1
DEF FIELD_ROW_1 EQU $9800+(0*32)+1
DEF FIELD_ROW_2 EQU $9800+(1*32)+1
DEF FIELD_ROW_3 EQU $9800+(2*32)+1
DEF FIELD_ROW_4 EQU $9800+(3*32)+1
DEF FIELD_ROW_5 EQU $9800+(4*32)+1
DEF FIELD_ROW_6 EQU $9800+(5*32)+1
DEF FIELD_ROW_7 EQU $9800+(6*32)+1
DEF FIELD_ROW_8 EQU $9800+(7*32)+1
DEF FIELD_ROW_9 EQU $9800+(8*32)+1
DEF FIELD_ROW_10 EQU $9800+(9*32)+1
DEF FIELD_ROW_11 EQU $9800+(10*32)+1
DEF FIELD_ROW_12 EQU $9800+(11*32)+1
DEF FIELD_ROW_13 EQU $9800+(12*32)+1
DEF FIELD_ROW_14 EQU $9800+(13*32)+1
DEF FIELD_ROW_15 EQU $9800+(14*32)+1
DEF FIELD_ROW_16 EQU $9800+(15*32)+1
DEF FIELD_ROW_17 EQU $9800+(16*32)+1
DEF FIELD_ROW_18 EQU $9800+(17*32)+1
DEF FIELD_ROW_19 EQU $9800+(18*32)+1
DEF FIELD_ROW_20 EQU $9800+(19*32)+1
DEF TILE_FIELD_EMPTY EQU 7
DEF TILE_PIECE_0 EQU 10
DEF TILE_0 EQU 110
DEF NEXT_BASE_X EQU 120
DEF NEXT_BASE_Y EQU 40
DEF HOLD_BASE_X EQU 120
DEF HOLD_BASE_Y EQU 80
DEF DIGIT_BASE_X EQU 112
DEF SCORE_BASE_Y EQU 115
DEF CLEVEL_BASE_Y EQU 136
DEF NLEVEL_BASE_Y EQU 148
; *****************************************************************************
; * *
; * Convenience Macros *
; * *
; *****************************************************************************
; Waits for VRAM to be safe to access. (Includes hblank.) ; Waits for VRAM to be safe to access. (Includes hblank.)
MACRO wait_vram MACRO wait_vram
.waitvram\@ .waitvram\@
@ -28,7 +113,6 @@ MACRO wait_vram
jr nz, .waitvram\@ jr nz, .waitvram\@
ENDM ENDM
; Waits for lcd to be in vblank. ; Waits for lcd to be in vblank.
MACRO wait_vblank MACRO wait_vblank
.waitvb\@ .waitvb\@
@ -38,7 +122,6 @@ MACRO wait_vblank
jr nz, .waitvb\@ jr nz, .waitvb\@
ENDM ENDM
; Waits for lcd to not be in vblank. ; Waits for lcd to not be in vblank.
MACRO wait_vblank_end MACRO wait_vblank_end
.waitvbe\@ .waitvbe\@
@ -48,25 +131,21 @@ MACRO wait_vblank_end
jr z, .waitvbe\@ jr z, .waitvbe\@
ENDM ENDM
; Sets the background palette to A. ; Sets the background palette to A.
MACRO set_bg_palette MACRO set_bg_palette
ldh [rBGP], a ldh [rBGP], a
ENDM ENDM
; Sets the object0 palette to A. ; Sets the object0 palette to A.
MACRO set_obj0_palette MACRO set_obj0_palette
ldh [rOBP0], a ldh [rOBP0], a
ENDM ENDM
; Sets the object1 palette to A. ; Sets the object1 palette to A.
MACRO set_obj1_palette MACRO set_obj1_palette
ldh [rOBP1], a ldh [rOBP1], a
ENDM ENDM
; Sets all palettes to A. ; Sets all palettes to A.
MACRO set_all_palettes MACRO set_all_palettes
set_bg_palette a set_bg_palette a
@ -79,6 +158,3 @@ ENDM
MACRO lb MACRO lb
ld \1, (LOW(\2) << 8) | LOW(\3) ld \1, (LOW(\2) << 8) | LOW(\3)
ENDM ENDM
ENDC

View File

@ -0,0 +1,34 @@
SECTION "Hardware Control Functions", ROM0
DisableAudio::
xor a, a
ldh [rNR52], a
ret
DisableLCDKeepingSettings::
ldh a, [rLCDC]
and LOW(~LCDCF_ON)
wait_vram
ldh [rLCDC], a
ret
DisableLCD::
wait_vram
xor a, a
ldh [rLCDC], a
ret
EnableLCD::
ldh a, [rLCDC]
or LCDCF_ON | LCDCF_BGON | LCDCF_OBJON
ldh [rLCDC], a
ret
SetTileDataBanks::
ldh a, [rLCDC]
or LCDCF_BLK01
ldh [rLCDC], a
ret

View File

@ -1,7 +1,3 @@
IF !DEF(INTERRUPTS_ASM)
DEF INTERRUPTS_ASM EQU 1
SECTION "Interrupt Initialization Functions", ROM0 SECTION "Interrupt Initialization Functions", ROM0
InitializeLCDCInterrupt:: InitializeLCDCInterrupt::
ld a, STATF_LYC ld a, STATF_LYC
@ -56,5 +52,3 @@ LCDCInterrupt_End:
pop af pop af
reti reti
ENDC

View File

@ -1,7 +1,3 @@
IF !DEF(MEMORY_ASM)
DEF MEMORY_ASM EQU 1
SECTION "Memory Functions", ROM0 SECTION "Memory Functions", ROM0
; Copies data from de to hl, bc bytes ; Copies data from de to hl, bc bytes
UnsafeMemCopy:: UnsafeMemCopy::
@ -36,6 +32,3 @@ UnsafeMemSet::
or a, c or a, c
jp nz, UnsafeMemSet jp nz, UnsafeMemSet
ret ret
ENDC

View File

@ -1,138 +1,34 @@
IF !DEF(RNG_ASM)
DEF RNG_ASM EQU 1
INCLUDE "globals.asm"
SECTION "RNG Variables", WRAM0
wRNGSeed: ds 4
wPieceHistory: ds 4
wNextPiece:: ds 1
section "RNG Functions", ROM0 section "RNG Functions", ROM0
StartNewGame:: NextByte::
; Do some bit fuckery on the seed using the gameboy's free-running timers.
ld hl, wRNGSeed
ldh a, [rDIV]
xor a, [hl]
ld [hl+], a
ldh a, [rTIMA]
xor a, [hl]
ld [hl+], a
ldh a, [rDIV]
xor a, [hl]
ld [hl+], a
ldh a, [rTIMA]
xor a, [hl]
ld [hl], a
; Initialize the next history.
ld hl, wPieceHistory
ld a, PIECE_Z
ld [hl+], a
ld [hl+], a
ld a, PIECE_S
ld [hl+], a
ld [hl], a
; Get the first piece and make sure it's not Z, S or O.
: call NextPiece
cp a, PIECE_Z
jr z, :-
cp a, PIECE_S
jr z, :-
cp a, PIECE_O
jr z, :-
; Store it.
ld hl, wPieceHistory
ld [hl], a
ld hl, wNextPiece
ld [hl], a
ret
GetNextPiece::
ld e, 7
: dec e
jr z, :+
call NextPiece
ld hl, wPieceHistory
cp a, [hl]
jr z, :-
inc hl
cp a, [hl]
jr z, :-
inc hl
cp a, [hl]
jr z, :-
inc hl
cp a, [hl]
jr z, :-
: ld hl, wNextPiece
ld [hl], a
ld b, a
ld hl, wPieceHistory+2
ld a, [hl+]
ld [hl], a
ld hl, wPieceHistory+1
ld a, [hl+]
ld [hl], a
ld hl, wPieceHistory
ld a, [hl+]
ld [hl-], a
ld a, b
ld [hl], a
ret
NextPiece:
call NextByte
and a, $07
cp a, 7
ret nz
dec a
ret
NextByte:
; Load seed ; Load seed
ld hl,wRNGSeed+3 ld hl,wRNGSeed+3
ld a, [hl-] ld a,[hl-]
ld b, a ld b,a
ld a, [hl-] ld a,[hl-]
ld c, a ld c,a
ld a, [hl-] ld a,[hl-]
; Multiply by 0x01010101 ; Multiply by 0x01010101
add [hl] add [hl]
ld d, a ld d,a
adc c adc c
ld c, a ld c,a
adc b adc b
ld b, a ld b,a
; Add 0x31415927 and write back ; Add 0x31415927 and write back
ld a, [hl] ld a,[hl]
add $27 add $27
ld [hl+], a ld [hl+],a
ld a, d ld a,d
adc $59 adc $59
ld [hl+], a ld [hl+],a
ld a, c ld a,c
adc $41 adc $41
ld [hl+], a ld [hl+],a
ld c, a ld c,a
ld a, b ld a,b
adc $31 adc $31
ld [hl], a ld [hl],a
ld b,a
ret ret
ENDC

View File

@ -1,7 +1,3 @@
IF !DEF(SPRITES_ASM)
DEF SPRITES_ASM EQU 1
SECTION "Shadow OAM", WRAM0, ALIGN[8] SECTION "Shadow OAM", WRAM0, ALIGN[8]
UNION UNION
wShadowOAM:: ds 160 wShadowOAM:: ds 160
@ -88,18 +84,12 @@ ApplyNext::
ld hl, sPieceXOffsets ld hl, sPieceXOffsets
ld de, sPieceYOffsets ld de, sPieceYOffsets
cp 0 cp 0
jr z, .skipoffn jp z, .skipoffn
.getoffn .getoffn
inc hl inc hl
inc hl
inc hl
inc hl
inc de
inc de
inc de
inc de inc de
dec a dec a
jr nz, .getoffn jp nz, .getoffn
.skipoffn .skipoffn
ld a, [hl+] ld a, [hl+]
add a, NEXT_BASE_X add a, NEXT_BASE_X
@ -154,18 +144,12 @@ ApplyHold::
ld hl, sPieceXOffsets ld hl, sPieceXOffsets
ld de, sPieceYOffsets ld de, sPieceYOffsets
cp 0 cp 0
jr z, .skipoffh jp z, .skipoffh
.getoffh .getoffh
inc hl inc hl
inc hl
inc hl
inc hl
inc de
inc de
inc de
inc de inc de
dec a dec a
jr nz, .getoffh jp nz, .getoffh
.skipoffh .skipoffh
ld a, [hl+] ld a, [hl+]
add a, HOLD_BASE_X add a, HOLD_BASE_X
@ -336,6 +320,3 @@ SetNumberSpritePositions::
ld [hl], a ld [hl], a
add a, 8 add a, 8
ret ret
ENDC

View File

@ -22,7 +22,7 @@
; SOFTWARE. ; SOFTWARE.
IF !DEF(STRUCTS_VERSION)
DEF STRUCTS_VERSION equs "3.0.1" DEF STRUCTS_VERSION equs "3.0.1"
MACRO structs_assert MACRO structs_assert
assert (\1), "rgbds-structs {STRUCTS_VERSION} bug. Please report at https://github.com/ISSOtm/rgbds-structs, and share the above stack trace *and* your code there!" assert (\1), "rgbds-structs {STRUCTS_VERSION} bug. Please report at https://github.com/ISSOtm/rgbds-structs, and share the above stack trace *and* your code there!"
@ -336,5 +336,3 @@ MACRO dstructs ; nb_structs, struct_type, instance_name
ENDR ENDR
PURGE STRUCT_ID PURGE STRUCT_ID
ENDM ENDM
ENDC

View File

@ -1,21 +1,18 @@
INCLUDE "globals.asm" INCLUDE "globals.asm"
INCLUDE "memory.asm" INCLUDE "memcpy.asm"
INCLUDE "hardwarectl.asm"
INCLUDE "interrupts.asm" INCLUDE "interrupts.asm"
INCLUDE "sprites.asm" INCLUDE "sprites.asm"
INCLUDE "rng.asm"
INCLUDE "res/tiles.inc" INCLUDE "res/tiles.inc"
INCLUDE "res/gameplay_map.inc" INCLUDE "res/gameplay_map.inc"
SECTION "Code Entry Point", ROM0 SECTION "Code Entry Point", ROM0
Main:: MainEntryPoint::
; Turn off LCD during initialization. ; Turn off LCD during initialization.
wait_vram call DisableLCD
xor a, a
ldh [rLCDC], a
; Save some power and turn off the audio. ; Save some power and turn off the audio.
xor a, a call DisableAudio
ldh [rNR52], a
; We use a single set of tiles for the entire game, so we copy it at the start. ; We use a single set of tiles for the entire game, so we copy it at the start.
ld de, Tiles ld de, Tiles
@ -30,9 +27,7 @@ Main::
call UnsafeMemCopy call UnsafeMemCopy
; Make sure both sprites and bg use the same tile data. ; Make sure both sprites and bg use the same tile data.
ldh a, [rLCDC] call SetTileDataBanks
or LCDCF_BLK01
ldh [rLCDC], a
; The tilemap is just for testing for now. ; The tilemap is just for testing for now.
ld de, GameplayTilemap ld de, GameplayTilemap
@ -49,11 +44,6 @@ Main::
ld a, PALETTE_REGULAR ld a, PALETTE_REGULAR
set_all_palettes set_all_palettes
; Get the timer going. It's used for RNG.
xor a, a
ldh [rTMA], a
ld a, TACF_262KHZ | TACF_START
; Zero out the ram where needed. ; Zero out the ram where needed.
call InitializeVariables call InitializeVariables
@ -61,17 +51,12 @@ Main::
call InitializeLCDCInterrupt call InitializeLCDCInterrupt
; And turn the LCD back on before we start. ; And turn the LCD back on before we start.
ldh a, [rLCDC] call EnableLCD
or LCDCF_ON | LCDCF_BGON | LCDCF_OBJON
ldh [rLCDC], a
; Make sure the first game loop starts just like all the future ones. ; Make sure the first game loop starts just like all the future ones.
wait_vblank wait_vblank
wait_vblank_end wait_vblank_end
; TEMP: Set up the game.
call StartNewGame
GameLoop:: GameLoop::
call GetInput call GetInput
@ -80,18 +65,10 @@ GameLoop::
; Handle gameplay here ; Handle gameplay here
; TODO ; TODO
ldh a, [hCtr] ld a, 0
inc a
and a, $1F
ldh [hCtr], a
jr nz, :+
call GetNextPiece
: ld a, [wNextPiece]
call ApplyNext call ApplyNext
ld a, [wNextPiece] ld a, 4
call ApplyHold call ApplyHold
ld hl, wSPRScore1 ld hl, wSPRScore1

View File

@ -1,5 +1,5 @@
#Emulicious settings file #Emulicious settings file
#Fri Oct 13 08:36:54 CEST 2023 #Wed Oct 11 08:17:53 CEST 2023
SouthPanelHeight=635 SouthPanelHeight=635
GameBoyErrorBreakpointMessage6= GameBoyErrorBreakpointMessage6=
GameBoyErrorBreakpointMessage5= GameBoyErrorBreakpointMessage5=
@ -46,7 +46,7 @@ GameBoyErrorBreakpointEnabled3=false
Gamepad0Key5=-1 Gamepad0Key5=-1
GameBoyErrorBreakpointEnabled2=false GameBoyErrorBreakpointEnabled2=false
Gamepad0Key4=-1 Gamepad0Key4=-1
WindowVideoViewerOpen=false WindowVideoViewerOpen=true
GameBoyErrorBreakpointEnabled1=false GameBoyErrorBreakpointEnabled1=false
Gamepad0Key3=-1 Gamepad0Key3=-1
GameBoyErrorBreakpointEnabled0=false GameBoyErrorBreakpointEnabled0=false
@ -63,7 +63,7 @@ WindowEventViewerWindowY=489
WindowEventViewerWindowX=1472 WindowEventViewerWindowX=1472
WindowSpriteViewerHeight=527 WindowSpriteViewerHeight=527
WindowSpriteViewerWidth=370 WindowSpriteViewerWidth=370
DebuggerWestPanelSelectedTab=0 DebuggerWestPanelSelectedTab=1
WindowMemoryTracerWindowHeight=289 WindowMemoryTracerWindowHeight=289
Gamepad0Key37=-1 Gamepad0Key37=-1
Gamepad0Key36=-1 Gamepad0Key36=-1
@ -76,7 +76,7 @@ Gamepad0Key32=-1
Gamepad0Key31=-1 Gamepad0Key31=-1
Gamepad0Key30=-1 Gamepad0Key30=-1
DebuggerSouthPanelSelectedTab=0 DebuggerSouthPanelSelectedTab=0
StackWidth=1311 StackWidth=940
SMSGamepadAKeyboard=false SMSGamepadAKeyboard=false
GameBoyErrorBreakpointCondition19= GameBoyErrorBreakpointCondition19=
GameBoyErrorBreakpointCondition18= GameBoyErrorBreakpointCondition18=
@ -148,33 +148,33 @@ Gamepad1Key21=-1
Gamepad1Key20=-1 Gamepad1Key20=-1
StackSplitLocation=320 StackSplitLocation=320
FontSize=13 FontSize=13
CodeFontSize=13
WindowEmuliciousHeight=781
CombineVideoViewers=true CombineVideoViewers=true
WindowEmuliciousHeight=781
CodeFontSize=13
WindowTilemapViewerY=544 WindowTilemapViewerY=544
WindowTilemapViewerX=1013
UninitializedMemoryBreakpointSuspend=true
GBGamepadKeyboard=false
MemoryTracer=true MemoryTracer=true
GBGamepadKeyboard=false
UninitializedMemoryBreakpointSuspend=true
WindowTilemapViewerX=1013
SMSGamepadBKeyboard=false SMSGamepadBKeyboard=false
DebuggerConsoleLogBreakpoints=true DebuggerConsoleLogBreakpoints=true
SMSGamepadBThreshold=50 SMSGamepadBThreshold=50
Gamepad1Key19=-1 Gamepad1Key19=-1
BankSwapAtPCBreakpointEnabled=false
Gamepad1Key18=-1 Gamepad1Key18=-1
BankSwapAtPCBreakpointEnabled=false
Gamepad1Key17=-1 Gamepad1Key17=-1
Gamepad1Key16=-1
WindowPaletteViewerWidth=485 WindowPaletteViewerWidth=485
GameBoyErrorBreakpointSuspend32=true Gamepad1Key16=-1
Recent0=C\:\\workspace\\dmgtris\\bin\\out.gb
Gamepad1Key15=-1 Gamepad1Key15=-1
Recent0=C\:\\workspace\\dmgtris\\bin\\out.gb
GameBoyErrorBreakpointSuspend32=true
Gamepad1Key14=-1 Gamepad1Key14=-1
Gamepad1Key13=-1 Gamepad1Key13=-1
Gamepad1Key12=-1 Gamepad1Key12=-1
GameBoyErrorBreakpointSuspend9=true
Gamepad1Key11=-1 Gamepad1Key11=-1
GameBoyErrorBreakpointSuspend8=true GameBoyErrorBreakpointSuspend9=true
Gamepad1Key10=-1 Gamepad1Key10=-1
GameBoyErrorBreakpointSuspend8=true
GameBoyErrorBreakpointSuspend7=true GameBoyErrorBreakpointSuspend7=true
GameBoyErrorBreakpointSuspend6=true GameBoyErrorBreakpointSuspend6=true
GameBoyErrorBreakpointSuspend5=true GameBoyErrorBreakpointSuspend5=true
@ -184,73 +184,73 @@ GameBoyErrorBreakpointSuspend2=true
GameBoyErrorBreakpointSuspend1=true GameBoyErrorBreakpointSuspend1=true
GameBoyErrorBreakpointSuspend0=true GameBoyErrorBreakpointSuspend0=true
Scale=5.0 Scale=5.0
DebuggerMemorySelectedAddress=390 DebuggerMemorySelectedAddress=0
WindowEmuliciousWidth=816 WindowEmuliciousWidth=816
GameBoyErrorBreakpointSuspend20=true GameBoyErrorBreakpointSuspend20=true
DataExecutionBreakpointCondition= DataExecutionBreakpointCondition=
WindowTilemapViewerWidth=404
BankSwapAtPCBreakpointCondition=
GameBoyErrorBreakpointMessage32= GameBoyErrorBreakpointMessage32=
BankSwapAtPCBreakpointCondition=
WindowTilemapViewerWidth=404
SMSbuttonsThreshold=50 SMSbuttonsThreshold=50
WindowTileViewerY=549 WindowTileViewerY=549
WindowTileViewerX=271
Gamepad1Key9=-1 Gamepad1Key9=-1
UninitializedMemoryBreakpointCondition= WindowTileViewerX=271
Gamepad1Key8=-1 Gamepad1Key8=-1
GameBoyErrorBreakpointSuspend19=true UninitializedMemoryBreakpointCondition=
Gamepad1Key7=-1 Gamepad1Key7=-1
GameBoyErrorBreakpointSuspend18=true GameBoyErrorBreakpointSuspend19=true
Gamepad1Key6=-1 Gamepad1Key6=-1
GameBoyErrorBreakpointSuspend17=true GameBoyErrorBreakpointSuspend18=true
Gamepad1Key5=-1 Gamepad1Key5=-1
GameBoyErrorBreakpointSuspend16=true GameBoyErrorBreakpointSuspend17=true
Gamepad1Key4=-1 Gamepad1Key4=-1
Gamepad1Key3=-1 GameBoyErrorBreakpointSuspend16=true
WindowVideoViewerY=275 WindowVideoViewerY=275
Gamepad1Key2=-1 Gamepad1Key3=-1
WindowVideoViewerX=946 WindowVideoViewerX=946
Gamepad1Key2=-1
Gamepad1Key1=-1 Gamepad1Key1=-1
Gamepad1Key0=-1 Gamepad1Key0=-1
GameBoyErrorBreakpointSuspend10=true GameBoyErrorBreakpointSuspend10=true
WindowEventViewerWindowDivider=309
WindowTilemapViewerHeight=744 WindowTilemapViewerHeight=744
WindowEventViewerWindowDivider=309
GameBoyErrorBreakpointMessage20= GameBoyErrorBreakpointMessage20=
WindowTileViewerWidth=467
MemoryTracerDisplayFileOffsetsForROM=true MemoryTracerDisplayFileOffsetsForROM=true
WindowDebuggerY=189 WindowTileViewerWidth=467
WindowDebuggerX=1113 WindowDebuggerY=158
WindowDebuggerX=939
Key37=-1 Key37=-1
Key36=-1 Key36=-1
WindowTileViewerOpen=false
GameBoyErrorBreakpointEnabled32=false
GameBoyErrorBreakpointCondition9=
Key35=-1 Key35=-1
GameBoyErrorBreakpointCondition8= GameBoyErrorBreakpointCondition9=
GameBoyErrorBreakpointEnabled32=false
WindowTileViewerOpen=false
Key34=-1 Key34=-1
GameBoyErrorBreakpointCondition7= GameBoyErrorBreakpointCondition8=
GameBoyErrorBreakpointMessage19=
Key33=-1 Key33=-1
DebuggerMemoryTabVisibleRect=0,0,0,0 GameBoyErrorBreakpointMessage19=
GameBoyErrorBreakpointMessage18= GameBoyErrorBreakpointCondition7=
GameBoyErrorBreakpointCondition6=
Key32=-1 Key32=-1
WindowEventViewerWindowWidth=930 GameBoyErrorBreakpointCondition6=
OutlineWidth=425 GameBoyErrorBreakpointMessage18=
GameBoyErrorBreakpointMessage17= DebuggerMemoryTabVisibleRect=0,0,0,0
GameBoyErrorBreakpointCondition5=
Key31=-1 Key31=-1
GameBoyErrorBreakpointMessage16= GameBoyErrorBreakpointCondition5=
GameBoyErrorBreakpointCondition4= GameBoyErrorBreakpointMessage17=
OutlineWidth=425
WindowEventViewerWindowWidth=930
Key30=-1 Key30=-1
GameBoyErrorBreakpointCondition4=
GameBoyErrorBreakpointMessage16=
GameBoyErrorBreakpointCondition3= GameBoyErrorBreakpointCondition3=
GameBoyErrorBreakpointCondition2= GameBoyErrorBreakpointCondition2=
Key9=40
GameBoyErrorBreakpointCondition1= GameBoyErrorBreakpointCondition1=
Key8=38 Key9=40
GameBoyErrorBreakpointCondition0= GameBoyErrorBreakpointCondition0=
Key8=38
Key7=83 Key7=83
GameBoyErrorBreakpointMessage10=
Key6=87 Key6=87
GameBoyErrorBreakpointMessage10=
Key5=65 Key5=65
Key4=68 Key4=68
Key3=10 Key3=10
@ -262,21 +262,21 @@ Update=2
Key29=-1 Key29=-1
Key28=10 Key28=10
Key27=-1 Key27=-1
Key26=-1
WindowSpriteViewerOpen=false WindowSpriteViewerOpen=false
Key26=-1
Key25=-1 Key25=-1
WindowTileViewerHeight=453
Key24=-1 Key24=-1
GameBoyErrorBreakpointEnabled20=false WindowTileViewerHeight=453
Key23=10 Key23=10
GameBoyErrorBreakpointEnabled20=false
Key22=-1 Key22=-1
Key21=-1 Key21=-1
BankSwapAtPCBreakpointSuspend=true
Key20=-1 Key20=-1
WindowEmuliciousY=489 BankSwapAtPCBreakpointSuspend=true
WindowEmuliciousX=666 WindowEmuliciousY=376
DebuggerMemorySelectedTab=RAM WindowEmuliciousX=146
WindowDebuggerWidth=1481 DebuggerMemorySelectedTab=HRAM
WindowDebuggerWidth=1110
GameBoyErrorBreakpointMessage9= GameBoyErrorBreakpointMessage9=
GameBoyErrorBreakpointMessage8= GameBoyErrorBreakpointMessage8=
GameBoyErrorBreakpointMessage7= GameBoyErrorBreakpointMessage7=