Skip to content

Commit d28bd74

Browse files
authored
remove unneeded legacy tables (#132)
orientationToSpriteTable is used to map the spawnId to the arbitrary sprite ID for the next piece. Reordering the sprites to match the game's piece ID order and reusing tetriminoTypeFromOrientation, this table can be removed. spawnOrientationFromOrientation may have been created in development when the RNG produced the orientation ID instead of the piece ID, but random spawn orientations weren't desired. As it's currently being used to convert the spawn ID to the same spawn ID, it can be removed. Reduces PRG usage by 38 bytes
1 parent 961aa7a commit d28bd74

File tree

4 files changed

+19
-28
lines changed

4 files changed

+19
-28
lines changed

src/data/orientation.asm

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,10 @@ orientationTable:
3030
.byte $00,$00,$7B,$01,$00,$FF,$00,$00
3131
.byte $FF,$00,$00,$FF,$00,$00,$FF,$00
3232

33-
; Only cares about orientations selected by spawnTable
34-
orientationToSpriteTable:
35-
.byte $00,$00,$06,$00,$00,$00,$00,$09
36-
.byte $08,$00,$0B,$07,$00,$00,$0A,$00
37-
.byte $00,$00,$0C
38-
3933
tetriminoTypeFromOrientation:
4034
.byte $00,$00,$00,$00,$01,$01,$01,$01
4135
.byte $02,$02,$03,$04,$04,$05,$05,$05
4236
.byte $05,$06,$06
4337
spawnTable:
4438
.byte $02,$07,$08,$0A,$0B,$0E,$12
4539
.byte $02
46-
spawnOrientationFromOrientation:
47-
.byte $02,$02,$02,$02,$07,$07,$07,$07
48-
.byte $08,$08,$0A,$0B,$0B,$0E,$0E,$0E
49-
.byte $0E,$12,$12

src/playstate/spawnnext.asm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ playState_spawnNextTetrimino:
4747
sta tetriminoY
4848
lda #$05
4949
sta tetriminoX
50-
ldx nextPiece
51-
lda spawnOrientationFromOrientation,x
50+
lda nextPiece
5251
sta currentPiece
5352
jsr incrementPieceStat
5453
jsr chooseNextTetrimino

src/sprites/loadsprite.asm

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ oamContentLookup:
5151
.addr sprite02Blank
5252
.addr sprite02Blank
5353
.addr sprite06TPiece
54-
.addr sprite07SPiece
54+
.addr sprite07JPiece
5555
.addr sprite08ZPiece
56-
.addr sprite09JPiece
57-
.addr sprite0ALPiece
58-
.addr sprite0BOPiece
56+
.addr sprite09OPiece
57+
.addr sprite0ASPiece
58+
.addr sprite0BLPiece
5959
.addr sprite0CIPiece
6060
.addr sprite0EHighScoreNameCursor
6161
.addr sprite0EHighScoreNameCursor
@@ -95,26 +95,26 @@ sprite06TPiece:
9595
.byte $00,$7B,$02,$FC,$00,$7B,$02,$04
9696
.byte $00,$7B,$02,$0C,$08,$7B,$02,$04
9797
.byte $FF
98-
sprite07SPiece:
99-
.byte $00,$7D,$02,$04,$00,$7D,$02,$0C
100-
.byte $08,$7D,$02,$FC,$08,$7D,$02,$04
98+
sprite07JPiece:
99+
.byte $00,$7D,$02,$FC,$00,$7D,$02,$04
100+
.byte $00,$7D,$02,$0C,$08,$7D,$02,$0C
101101
.byte $FF
102102
sprite08ZPiece:
103103
.byte $00,$7C,$02,$FC,$00,$7C,$02,$04
104104
.byte $08,$7C,$02,$04,$08,$7C,$02,$0C
105105
.byte $FF
106-
sprite09JPiece:
107-
.byte $00,$7D,$02,$FC,$00,$7D,$02,$04
108-
.byte $00,$7D,$02,$0C,$08,$7D,$02,$0C
106+
sprite09OPiece:
107+
.byte $00,$7B,$02,$00,$00,$7B,$02,$08
108+
.byte $08,$7B,$02,$00,$08,$7B,$02,$08
109+
.byte $FF
110+
sprite0ASPiece:
111+
.byte $00,$7D,$02,$04,$00,$7D,$02,$0C
112+
.byte $08,$7D,$02,$FC,$08,$7D,$02,$04
109113
.byte $FF
110-
sprite0ALPiece:
114+
sprite0BLPiece:
111115
.byte $00,$7C,$02,$FC,$00,$7C,$02,$04
112116
.byte $00,$7C,$02,$0C,$08,$7C,$02,$FC
113117
.byte $FF
114-
sprite0BOPiece:
115-
.byte $00,$7B,$02,$00,$00,$7B,$02,$08
116-
.byte $08,$7B,$02,$00,$08,$7B,$02,$08
117-
.byte $FF
118118
sprite0CIPiece:
119119
.byte $04,$7B,$02,$F8,$04,$7B,$02,$00
120120
.byte $04,$7B,$02,$08,$04,$7B,$02,$10

src/sprites/piece.asm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ stageSpriteForNextPiece:
145145
lda #$77
146146
sta spriteYOffset
147147
ldx nextPiece
148-
lda orientationToSpriteTable,x
148+
lda tetriminoTypeFromOrientation,x
149+
clc
150+
adc #$6 ; piece sprites start at index 6
149151
sta spriteIndexInOamContentLookup
150152
jmp loadSpriteIntoOamStaging
151153

0 commit comments

Comments
 (0)