Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8f52131
Changes for using ecm's LZSA depacker
ecm-pushbx Jul 28, 2026
7943b96
Update crabs.cpp from prior commit
ecm-pushbx Jul 28, 2026
dd6b245
Project files update for E:\TC\ pathnames and use lzsa.obj
ecm-pushbx Jul 28, 2026
9d087fe
Switch to use LZSA2 compression format
ecm-pushbx Jul 28, 2026
1626be5
In planize.py emit the uncompressed binaries as .bin files
ecm-pushbx Jul 28, 2026
f35b04d
In planize.py emit .sa files rather than .lz4
ecm-pushbx Jul 28, 2026
55fed26
Allow selecting format from planize.py command line
ecm-pushbx Jul 29, 2026
658d579
Add raw LZSA variants to planize.py
ecm-pushbx Jul 29, 2026
b3f6f3a
Add benchmark mode to show a single flag and immediately exit
ecm-pushbx Jul 30, 2026
88a7a0c
Fix a bug in benchmark flag not found error
ecm-pushbx Jul 30, 2026
0809641
Rename depack function name to just _depacker
ecm-pushbx Jul 30, 2026
8074e29
Rename depacker object filename to depacker.obj
ecm-pushbx Jul 30, 2026
a7406d1
Display benchmark flag name and depacker name
ecm-pushbx Jul 30, 2026
26ef912
Add repetition parameter to benchmark code
ecm-pushbx Jul 30, 2026
1e9649d
Add _depackername string and rename _depacker for LZ4_8088
ecm-pushbx Jul 30, 2026
80855c4
In planize.py accept lzsaXr aliases
ecm-pushbx Jul 30, 2026
96a62df
Add _depackerattribution string constant to LZ4_8088
ecm-pushbx Jul 31, 2026
75cb188
Use depackerattribution string instead of hardcoding it
ecm-pushbx Jul 31, 2026
1427024
Call savetime and disptime from time.obj file
ecm-pushbx Jul 31, 2026
910759b
Drop old benchmark display from main, use only disptime
ecm-pushbx Jul 31, 2026
d188525
Add lzsa1jmp alias for lzsa1raw to planize.py
ecm-pushbx Aug 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions LZ4_8088.ASM
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

CODESEG

PUBLIC _lz4_decompress
PUBLIC _depacker

; Must declare this in the code segment.
SHR4table:
Expand Down Expand Up @@ -89,7 +89,7 @@ SHR4table:
; After Pavel's speedups:
; New timings: shuttle 81982 text 43664 robotron 296081 +++

PROC _lz4_decompress CPP far
PROC _depacker CPP far
ARG inb:DWORD, outb:DWORD
USES DI,SI,BP
push ds ;preserve compiler assumptions
Expand Down Expand Up @@ -223,7 +223,13 @@ buildmcount: ;build full match length count - AX is 0
pop ds ;restore compiler assumptions
ret

ENDP _lz4_decompress
ENDP _depacker

DATASEG
PUBLIC _depackername
_depackername db "lz4_8088",0

PUBLIC _depackerattribution
_depackerattribution db "lz4_8088 decompression code: Jim Leonard",0

END
12,879 changes: 5,752 additions & 7,127 deletions crabs.cpp

Large diffs are not rendered by default.

47 changes: 44 additions & 3 deletions crabs/planize.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,26 @@ def group_in_threes(seq):
('transcrab_plane{}','trans_crab_flag','crabtran256.png'),
('autistic_plane{}','autistic_pride_flag','autistic_pride_flag_256.png'),
]
format = "lzsa2"
if len(sys.argv) > 1 and sys.argv[1] is not None:
format = sys.argv[1].lower()
aliasformat = format
if format == "lz4ecm":
format = "lz4"
elif format in ["lz4_8088", "lz48088", "lz4trixter"]:
format = "lz4old"
elif format == "lzsa2r":
format = "lzsa2raw"
elif format in ["lzsa1r", "lzsa1trixter", "lzsa1jmp"]:
format = "lzsa1raw"
if format in ["lzsa2", "lzsa2raw", "lzsa1", "lzsa1raw", "lz4", "lz4old"]:
if aliasformat == format:
print "Format: %s" % format
else:
print "Format: %s (alias of %s)" % (aliasformat, format)
else:
print "Error: Unknown format \"%s\"" % format
sys.exit(1)
with open(os.path.join('..','crabs.cpp'),'w') as outcrabs:
print >>outcrabs,"""
#include <stdlib.h>
Expand Down Expand Up @@ -55,19 +75,40 @@ def group_in_threes(seq):
cbuffer.append(chr(v))
outbuffers.append(cbuffer)
for i,buffer in enumerate(outbuffers):
with open('{}.bin'.format(variable_name.format(i)), 'wb') as of:
of.write(''.join(buffer))
if format == "lz4old":
cmd = ['lz4demo', '-c2s', 'stdin', TEMPFILE]
ext = "ol4"
elif format == "lz4":
cmd = ['lz4', '-f', '--best', 'stdin', TEMPFILE]
ext = "lz4"
elif format == "lzsa1":
cmd = ['lzsa', '-N', '-S', '-f', '1', '--prefer-ratio', '-v', '-', TEMPFILE]
ext = "sa1"
elif format == "lzsa1raw":
cmd = ['lzsa', '-r', '-f', '1', '--prefer-ratio', '-v', '-', TEMPFILE]
ext = "rs1"
elif format == "lzsa2":
cmd = ['lzsa', '-N', '-S', '-f', '2', '--prefer-ratio', '-v', '-', TEMPFILE]
ext = "sa2"
elif format == "lzsa2raw":
cmd = ['lzsa', '-r', '-f', '2', '--prefer-ratio', '-v', '-', TEMPFILE]
ext = "rs2"
proc=subprocess.Popen(
['lz4', '-c2s', 'stdin', TEMPFILE],
cmd,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
stdout,_=proc.communicate(''.join(buffer))
dumpname = '%s.%s' % (variable_name.format(i), ext)
if proc.returncode!=0:
print 'Failed to compress {}'.format(outfile)
print 'Failed to compress %s' % dumpname
sys.exit()
with open(TEMPFILE,'rb') as f:
inbytes=f.read()
shutil.copyfile(TEMPFILE,'{}.lz4'.format(variable_name.format(i)))
shutil.copyfile(TEMPFILE, dumpname)
lines=textwrap.wrap(', '.join(['0x{:02x}'.format(ord(x)) for x in inbytes]))

local_var = variable_name.format(i)
Expand Down
6 changes: 3 additions & 3 deletions display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static int polygon_points[32];

char far * volatile vga_ptr = (char far *)MK_FP(0xA000,0);

extern "C" unsigned int far lz4_decompress(const void far *inbuffer, void* far outbuffer);
extern "C" unsigned int far depacker(const void far *inbuffer, void* far outbuffer);

#define PLANE_SIZE 38656 // 640*480/8 + 256

Expand Down Expand Up @@ -112,7 +112,7 @@ void DecompressStringIntoPlane(const unsigned char far *compressed_plane, int pl

SetVGAMapRegister(1 << plane);

lz4_decompress((const void far *)compressed_plane, plane_buffer);
depacker((const void far *)compressed_plane, plane_buffer);
memcpy(vga_ptr, plane_buffer, PLANE_SIZE);
farfree(plane_buffer);

Expand Down Expand Up @@ -210,4 +210,4 @@ void GraphicsCommand::render(){
}
}

}
}
48 changes: 40 additions & 8 deletions vgapride.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
#include "keys.h"
#include <alloc.h>

extern "C" const char far depackername[];
extern "C" const char far depackerattribution[];
extern "C" void far savetime(void);
extern "C" void far disptime(const char far * flagname, unsigned repeat);

unsigned int waitForKey(){
unsigned int ret=getch();
if(ret==0){
Expand Down Expand Up @@ -76,25 +81,52 @@ int startGraphics(){

int main(int argc, char**argv){
int i; // Borland Turbo C++ has leaky forloops
unsigned namearg = 1, benchmark = 0, repeat = 1, repeatoriginal = 1;

if(argc!=2){
if ((argc == 3 || argc == 4)
&& (stricmp(argv[1], "benchmark") == 0
|| stricmp(argv[1], "bench") == 0)) {
++ namearg;
++ benchmark;
if (argc == 4) {
repeat = atoi(argv[3]);
if (!repeat) {
printf("\nInvalid repeat amount: \"%s\"\n",argv[3]);
return 2;
}
repeatoriginal = repeat;
}
} else if (argc !=2 ) {
displayUsage();
return 2;
}
for(i=0;;i++){
Flag *flag=PRIDE_FLAGS[i];
if(flag==NULL)break;
if(flag->match(argv[1])){
int ret=startGraphics();
if(flag->match(argv[namearg])){
int ret;
savetime();
ret = startGraphics();
if(ret!=0){
return 0;
return 0;
}
while (repeat--) {
showFlag(flag, false);
}
if (!benchmark) {
getch();
}
showFlag(flag, false);
getch();
closegraph();
if (benchmark) {
disptime(argv[namearg], repeatoriginal);
}
return 0;
}
}
if (benchmark) {
printf("\nFlag \"%s\" not found.\n",argv[namearg]);
return 2;
}
// If we didn't find a flag, see if they were asking for a LIST
if(stricmp(argv[1], "list")==0){
displayFlags();
Expand Down Expand Up @@ -170,7 +202,7 @@ void quickFlags(){

void displayUsage(){
printf("VGAPride %s by Foone Turing (@foone@digipres.club), 2022-2023. Other credits:\n", VERSION);
printf(" * lz4_8088 decompression code: Jim Leonard\n");
printf(" * %s\n", depackerattribution);
printf(" * Aegosexual Flag: Keiya (@keiyakins)\n");
printf(" * Many flags: Rebecca G. Bettencourt (@RebeccaRGB)\n");
printf(" * Autistic Pride Flag licensed under a Creative Commons Attribution-ShareAlike 4.0 International License, from autisticempire.com/autistic-pride/\n");
Expand All @@ -180,4 +212,4 @@ void displayUsage(){
printf("\nQuick List:\n");
quickFlags();

}
}
Binary file modified vgapride.dsk
Binary file not shown.
Binary file modified vgapride.prj
Binary file not shown.