Skip to content

Commit

Permalink
twoplayer: Move from unreferenced_data4 to legal_screen_nametable
Browse files Browse the repository at this point in the history
The nametable is RLE compressed to make room.
  • Loading branch information
ejona86 committed Apr 26, 2020
1 parent 7f01ed7 commit 5eabd4b
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 11 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ build/tetris-test: tetris.nes build/tetris.nes

twoplayer: build/twoplayer.dist.ips
build/twoplayer-CHR-01.chr.ips.o: build/twoplayer.chrs/fake
build/twoplayer.o: build/tetris.inc build/twoplayer_game.nam.rle build/twoplayer_game_top.nam.rle build/tournament.nam.rle build/tetris-CHR-00.chr build/twoplayer-CHR-01.chr
build/twoplayer.o: build/tetris.inc build/twoplayer_game.nam.rle build/twoplayer_game_top.nam.rle build/tournament.nam.rle build/tetris-CHR-00.chr build/twoplayer-CHR-01.chr build/legal_screen_nametable.nam.rle
# Diff base file. There is a corresponding .diff file
build/twoplayer-tetris-PRG.s: build/tetris-PRG.s
build/twoplayer-CHR-01.chr.ips: build/ips.o build/twoplayer-CHR-01.chr.ips.o
Expand Down Expand Up @@ -86,6 +86,8 @@ build/game_palette.pal: build/tetris-PRG.bin
build/menu_palette.pal: build/tetris-PRG.bin
# +3 for buildCopyToPpu header
tail -c +$$((0xAD2B - 0x8000 + 3 + 1)) $< | head -c 16 > $@
build/legal_screen_nametable.nam: build/tetris-PRG.bin
tail -c +$$((0xADB8 - 0x8000 + 1)) $< | head -c $$((1024/32*35)) | LC_ALL=C awk 'BEGIN {RS=".{35}";ORS=""} {print substr(RT, 4)}' > $@
build/game_nametable.nam: build/tetris-PRG.bin
tail -c +$$((0xBF3C - 0x8000 + 1)) $< | head -c $$((1024/32*35)) | LC_ALL=C awk 'BEGIN {RS=".{35}";ORS=""} {print substr(RT, 4)}' > $@
build/level_menu_nametable.nam: build/tetris-PRG.bin
Expand Down
8 changes: 5 additions & 3 deletions tetris-PRG.info
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ GLOBAL {
STARTADDR $8000;
};

SEGMENT { START $8000; END $D6C8; NAME "PRG_chunk1"; };
SEGMENT { START $8000; END $ADB7; NAME "PRG_chunk1"; };
SEGMENT { START $ADB8; END $B218; NAME "legal_screen_nametable"; };
SEGMENT { START $B219; END $D6C8; NAME "PRG_chunk2"; };
SEGMENT { START $D6C9; END $DCFF; NAME "unreferenced_data1"; };
SEGMENT { START $DD00; END $F9EA; NAME "PRG_chunk2"; };
SEGMENT { START $DD00; END $F9EA; NAME "PRG_chunk3"; };
SEGMENT { START $F9EB; END $FEFF; NAME "unreferenced_data4"; };
SEGMENT { START $FF00; END $FFF9; NAME "PRG_chunk3"; };
SEGMENT { START $FF00; END $FFF9; NAME "PRG_chunk4"; };
SEGMENT { START $FFFA; END $FFFF; NAME "VECTORS"; };

# "canon" names match those in https://meatfighter.com/nintendotetrisai/
Expand Down
6 changes: 4 additions & 2 deletions tetris.nes.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ SEGMENTS {
HEADER: load = HDR, type = ro;
CHR: load = CHR, type = ro;
PRG_chunk1: load = PRG, type = ro;
legal_screen_nametable:load = PRG, type = ro;
PRG_chunk2: load = PRG, type = ro, start = $B219;
unreferenced_data1:load = PRG, type = ro;
PRG_chunk2: load = PRG, type = ro, start = $DD00;
PRG_chunk3: load = PRG, type = ro, start = $DD00;
unreferenced_data4:load = PRG, type = ro;
PRG_chunk3: load = PRG, type = ro, start = $FF00;
PRG_chunk4: load = PRG, type = ro, start = $FF00;
VECTORS: load = PRG, type = ro, start = $FFFA;
}
14 changes: 13 additions & 1 deletion twoplayer-tetris-PRG.s.diff
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,19 @@
.addr gameModeState_checkForResetKeyCombo
.addr gameModeState_startButtonHandling
.addr gameModeState_vblankThenRunState2
@@ -527,11 +560,12 @@ gameMode_legalScreen:
@@ -517,21 +550,22 @@ gameMode_legalScreen:
jsr changeCHRBank0
lda #$00
jsr changeCHRBank1
jsr bulkCopyToPpu
.addr legal_screen_palette
- jsr bulkCopyToPpu
- .addr legal_screen_nametable
+ jsr copyRleNametableToPpu
+ .addr legal_screen_nametable_rle
jsr waitForVBlankAndEnableNmi
jsr updateAudioWaitForNmiAndResetOamStaging
jsr updateAudioWaitForNmiAndEnablePpuRendering
jsr updateAudioWaitForNmiAndResetOamStaging
lda #$00
ldx #$02
Expand Down
5 changes: 5 additions & 0 deletions twoplayer.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.ifndef __TWOPLAYERSIMPORT
.import copyRleNametableToPpu
.import legal_screen_nametable_rle
.endif

.ifdef TOURNAMENT_MODE

; Enable NEXT_ON_TOP. -DNEXT_ON_TOP is the same as -DNEXT_ON_TOP=0
Expand Down
10 changes: 6 additions & 4 deletions twoplayer.nes.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ SEGMENTS {
HEADER: load = HDR, type = ro;
CHR: load = CHR, type = ro;
PRG_chunk1: load = PRG, type = ro;
legal_screen_nametable:load = TRASH, type = ro;
CODE2: load = PRG, type = ro;
PRG_chunk2: load = PRG, type = ro, start = $B219;
unreferenced_data1:load = TRASH, type = ro;
CODE: load = PRG, type = ro;
PRG_chunk2: load = PRG, type = ro, start = $DD00;
unreferenced_data4:load = TRASH, type = ro;
CODE2: load = PRG, type = ro;
PRG_chunk3: load = PRG, type = ro, start = $FF00;
PRG_chunk3: load = PRG, type = ro, start = $DD00;
unreferenced_data4:load = PRG, type = ro;
PRG_chunk4: load = PRG, type = ro, start = $FF00;
VECTORS: load = PRG, type = ro, start = $FFFA;
}
6 changes: 6 additions & 0 deletions twoplayer.s
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

.include "build/tetris.inc"
.include "tetris-tbl.inc"
__TWOPLAYERSIMPORT = 1
.include "twoplayer.inc"

.ifdef TOURNAMENT_MODE
Expand Down Expand Up @@ -131,6 +132,7 @@ twoplayer_game_nametable:
.endif

copyRleNametableToPpu:
.export copyRleNametableToPpu
jsr copyAddrAtReturnAddressToTmp_incrReturnAddrBy2
ldx PPUSTATUS
lda #$20
Expand Down Expand Up @@ -545,6 +547,10 @@ isStartNewlyPressed:

.segment "CODE2"

legal_screen_nametable_rle:
.export legal_screen_nametable_rle
.incbin "build/legal_screen_nametable.nam.rle"

demo_pollController_mod_after := $9D66
demo_pollController_mod_skip := $9D6A
demo_pollController_mod:
Expand Down

0 comments on commit 5eabd4b

Please sign in to comment.