-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
legal_screen_nametable compresses to 294 bytes, vs 221 with Konami RLE. If twoplayer wasn't also including the two-player playfield, it would be a good choice.
- Loading branch information
Showing
3 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Encode input using Stripe RLE compression (Tetris variation) | ||
# | ||
# Intended to be run with LC_ALL=C and 'basenc --base16 -w2' as input and | ||
# 'basenc --base16 -d' on output | ||
|
||
# variable addr can be set to change the destination PPU address | ||
# input is pairs of hex digits, each followed by newline | ||
# output is chunks of hex digits, with newlines between each chunk | ||
|
||
BEGIN { | ||
runlen=0 | ||
if (addr == "") { | ||
addr=0x2000 | ||
} | ||
} | ||
|
||
runlen != 0 && lastbyte == $0 { | ||
runlen++ | ||
if (runlen == 0x40) { | ||
printf("%04X%02X%s\n", addr, 0x40, lastbyte) | ||
addr+=runlen | ||
runlen=0 | ||
} | ||
next | ||
} | ||
|
||
runlen != 0 && lastbyte != $0 { | ||
printf("%04X%02X%s\n", addr, 0x40+runlen, lastbyte) | ||
addr+=runlen | ||
runlen=0 | ||
} | ||
|
||
{ | ||
literal=$0 | ||
runlen=1 | ||
lastbyte=$0 | ||
while (getline) { | ||
literal=literal $0 | ||
if (lastbyte != $0) { | ||
runlen=1 | ||
} else { | ||
runlen++ | ||
# Optimal is 4 if next stripe is a run, and 7 if | ||
# literal. Assume a literal typically follows a run. | ||
if ((runlen == 4 && runlen*2 == length(literal)) \ | ||
|| runlen == 7) { | ||
literal=substr(literal, 1, length(literal)-runlen*2) | ||
if (literal == "") { | ||
next | ||
} else { | ||
break | ||
} | ||
} | ||
} | ||
if (length(literal)/2 == 0x40) { | ||
runlen=0 | ||
break | ||
} | ||
lastbyte=$0 | ||
} | ||
printf("%04X%02X%s\n", addr, (length(literal)/2)%0x40, literal) | ||
addr+=length(literal)/2 | ||
} | ||
|
||
END { | ||
if (runlen != 0) { | ||
printf("%04X%02X%s\n", addr, 0x40+runlen, lastbyte) | ||
addr+=runlen | ||
} | ||
print "FF" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters