Skip to content

Commit 6ef6a54

Browse files
committed
streamline process of 6502 binary implementation, make --effect and --relocate available for either small and fast
1 parent 5e7a284 commit 6ef6a54

File tree

3 files changed

+162
-135
lines changed

3 files changed

+162
-135
lines changed

packer/dali/Makefile

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ all: dali
4848
#
4949
#dali: dali.o $(DALI_OBJS)
5050

51-
dali: dali.c $(SALVADOR_SRC) sfx_small.h sfx_fast.h sfx_effect.h
51+
dali: dali.c $(SALVADOR_SRC) sfx.h
5252
@echo "Building dali..."
5353
$(VR)$(CC) dali.c $(SALVADOR_SRC) $(DALI_CFLAGS) -o $@
5454
ifdef win
@@ -62,41 +62,39 @@ endif
6262
testfile.lz: ../../benchmark/files/b dali
6363
./dali -o $@ $<
6464

65-
example.prg: example.asm dali dzx0_dali.asm testfile.lz
65+
example.prg: example.asm dali dzx0_dali.asm testfile.lz
6666
$(VR)$(ACME) $(ACME_OPTS) -o $@ $<
6767

68-
sfx_effect.h: sfx.asm
69-
@echo "Creating sfx_effect.h..."
70-
$(VR)$(ACME) $(ACME_OPTS) -DSFX_EFFECT=1 --labeldump $(basename $@).lst -o $(basename $@) $<
71-
$(VR)grep 'DALI' $(basename $@).lst | sed -e 's/[[:space:]]*;[[:space:]]*.*//g' -e 's/[[:space:]]*//g' -e 's/\=\$$/ 0x/g' -e 's/^/#define /' > $@
68+
sfx.h: sfx.asm
69+
@echo "Creating sfx.h..."
70+
$(VR)$(ACME) $(ACME_OPTS) -DSFX_EFFECT=1 -DSFX_SMALL=1 -o $(basename $@) $<
71+
72+
$(VR)echo 'static const char decruncher_small_effect[] = {' >> $@
73+
@#create a hexdump, add a marker (+) where lines are truncated (each 50 chars = 8 bytes per line), substitute marker (+) with newline (use tr here, as bsd-sed fails on \n), add identation to each line
74+
$(VR)hexdump -ve '1/1 "0x%.2x,"' $(basename $@) | sed -e 's/,$$/+/g' -e 's/.\{50\}/&+/g' | tr -s '+' '\n' | sed 's/^/& /g' >> $@
75+
$(VR)echo '};' >> $@
76+
77+
$(VR)$(ACME) $(ACME_OPTS) -DSFX_EFFECT=1 -DSFX_FAST=1 -o $(basename $@) $<
7278
$(VR)echo 'static const char decruncher_effect[] = {' >> $@
7379
@#create a hexdump, add a marker (+) where lines are truncated (each 50 chars = 8 bytes per line), substitute marker (+) with newline (use tr here, as bsd-sed fails on \n), add identation to each line
7480
$(VR)hexdump -ve '1/1 "0x%.2x,"' $(basename $@) | sed -e 's/,$$/+/g' -e 's/.\{50\}/&+/g' | tr -s '+' '\n' | sed 's/^/& /g' >> $@
7581
$(VR)echo '};' >> $@
76-
$(VR)rm $(basename $@).lst $(basename $@)
7782

78-
sfx_small.h: sfx.asm
79-
@echo "Creating sfx_small.h..."
80-
$(VR)$(ACME) $(ACME_OPTS) -DSFX_SMALL=1 --labeldump $(basename $@).lst -o $(basename $@) $<
81-
$(VR)grep 'DALI' $(basename $@).lst | sed -e 's/[[:space:]]*;[[:space:]]*.*//g' -e 's/[[:space:]]*//g' -e 's/\=\$$/ 0x/g' -e 's/^/#define /' > $@
83+
$(VR)$(ACME) $(ACME_OPTS) -DSFX_SMALL=1 -o $(basename $@) $<
8284
$(VR)echo 'static const char decruncher_small[] = {' >> $@
8385
@#create a hexdump, add a marker (+) where lines are truncated (each 50 chars = 8 bytes per line), substitute marker (+) with newline (use tr here, as bsd-sed fails on \n), add identation to each line
8486
$(VR)hexdump -ve '1/1 "0x%.2x,"' $(basename $@) | sed -e 's/,$$/+/g' -e 's/.\{50\}/&+/g' | tr -s '+' '\n' | sed 's/^/& /g' >> $@
8587
$(VR)echo '};' >> $@
86-
$(VR)rm $(basename $@).lst $(basename $@)
8788

88-
sfx_fast.h: sfx.asm
89-
@echo "Creating sfx_fast.h..."
90-
$(VR)$(ACME) $(ACME_OPTS) -DSFX_FAST=1 --labeldump $(basename $@).lst -o $(basename $@) $<
91-
$(VR)grep 'DALI' $(basename $@).lst | sed -e 's/[[:space:]]*;[[:space:]]*.*//g' -e 's/[[:space:]]*//g' -e 's/\=\$$/ 0x/g' -e 's/^/#define /' > $@
89+
$(VR)$(ACME) $(ACME_OPTS) -DSFX_FAST=1 -o $(basename $@) $<
9290
$(VR)echo 'static const char decruncher[] = {' >> $@
9391
@#create a hexdump, add a marker (+) where lines are truncated (each 50 chars = 8 bytes per line), substitute marker (+) with newline (use tr here, as bsd-sed fails on \n), add identation to each line
9492
$(VR)hexdump -ve '1/1 "0x%.2x,"' $(basename $@) | sed -e 's/,$$/+/g' -e 's/.\{50\}/&+/g' | tr -s '+' '\n' | sed 's/^/& /g' >> $@
9593
$(VR)echo '};' >> $@
96-
$(VR)rm $(basename $@).lst $(basename $@)
94+
@rm $(basename $@)
9795

9896
clean:
99-
$(VR)-rm dali dali.exe sfx_small.h sfx_fast.h sfx_effect.h example.prg testfile.lz
97+
$(VR)-rm dali dali.exe sfx.h example.prg testfile.lz
10098
# $(VR)-rm $(SALVADOR_PATH)/*.o
10199
# $(VR)-rm $(SALVADOR_LIB_PATH)/*.o
102100
$(VR)-make -C salvador clean

packer/dali/dali.c

Lines changed: 112 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
#include <stdio.h>
33
#include <stdlib.h>
44
#include <string.h>
5-
#include "sfx_small.h"
6-
#include "sfx_fast.h"
7-
#include "sfx_effect.h"
5+
#include "sfx.h"
86

97
#define BUFFER_SIZE 65536 /* must be > MAX_OFFSET */
108
#define INITIAL_OFFSET 1
@@ -13,6 +11,7 @@
1311
#define TRUE 1
1412
#define DALI_BITS_LEFT 1
1513
#define DALI_ELIAS_LE 1
14+
#define DALI_VARS_SIZE 18
1615

1716
//include salvador and rename main
1817
#define main salvador_main
@@ -57,7 +56,7 @@ typedef struct ctx {
5756
int sfx_small;
5857
int sfx_effect;
5958
int sfx_size;
60-
char *sfx_code;
59+
unsigned char *sfx_code;
6160
int lz_bits;
6261

6362
int exit_on_warn;
@@ -310,8 +309,32 @@ void reencode_packed_stream(ctx* ctx) {
310309
}
311310
}
312311

312+
unsigned int get_var(ctx* ctx, unsigned int pos) {
313+
return ctx->sfx_code[pos] + (ctx->sfx_code[pos + 1] << 8);
314+
}
315+
313316
void write_reencoded_stream(ctx* ctx) {
314317
FILE *fp = NULL;
318+
unsigned int dali_sfx_src;
319+
unsigned int dali_src;
320+
unsigned int dali_dst;
321+
unsigned int dali_sfx_addr;
322+
unsigned int dali_data_end;
323+
unsigned int dali_data_size_hi;
324+
unsigned int dali_01;
325+
unsigned int dali_cli;
326+
//int dali_effect_code;
327+
328+
unsigned int var_dali_sfx_src;
329+
unsigned int var_dali_src;
330+
unsigned int var_dali_dst;
331+
unsigned int var_dali_sfx_addr;
332+
unsigned int var_dali_data_end;
333+
unsigned int var_dali_data_size_hi;
334+
unsigned int var_dali_01;
335+
unsigned int var_dali_cli;
336+
//unsigned int var_dali_effect_code;
337+
315338
/* write reencoded output file */
316339
fp = fopen(ctx->output_name, "wb");
317340
if (!fp) {
@@ -323,98 +346,98 @@ void write_reencoded_stream(ctx* ctx) {
323346
if (ctx->sfx) {
324347
printf("Creating sfx with start-address $%04x\n", ctx->sfx_addr);
325348
if (ctx->sfx_small) {
326-
ctx->sfx_size = sizeof(decruncher_small);
327-
/* copy over to change values in code */
328-
ctx->sfx_code = (char *)malloc(ctx->sfx_size);
329-
memcpy (ctx->sfx_code, decruncher_small, ctx->sfx_size);
330-
331-
/* setup jmp target after decompression */
332-
ctx->sfx_code[DALI_SMALL_SFX_ADDR + 0] = ctx->sfx_addr & 0xff;
333-
ctx->sfx_code[DALI_SMALL_SFX_ADDR + 1] = (ctx->sfx_addr >> 8) & 0xff;
334-
335-
/* setup decompression destination */
336-
ctx->sfx_code[DALI_SMALL_DST + 0] = ctx->cbm_orig_addr & 0xff;
337-
ctx->sfx_code[DALI_SMALL_DST + 1] = (ctx->cbm_orig_addr >> 8) & 0xff;
338-
339-
/* setup compressed data src */
340-
ctx->sfx_code[DALI_SMALL_SRC + 0] = (0x10000 - ctx->reencoded_index) & 0xff;
341-
ctx->sfx_code[DALI_SMALL_SRC + 1] = ((0x10000 - ctx->reencoded_index) >> 8) & 0xff;
342-
343-
/* setup compressed data end */
344-
ctx->sfx_code[DALI_SMALL_DATA_END + 0] = (0x801 + ctx->sfx_size - 2 + ctx->reencoded_index - 0x100) & 0xff;
345-
ctx->sfx_code[DALI_SMALL_DATA_END + 1] = ((0x801 + ctx->sfx_size - 2 + ctx->reencoded_index - 0x100) >> 8) & 0xff;
346-
347-
ctx->sfx_code[DALI_SMALL_DATA_SIZE_HI] = 0xff - (((ctx->reencoded_index + 0x100) >> 8) & 0xff);
348-
} else if (ctx->sfx_effect) {
349-
ctx->sfx_size = sizeof(decruncher_effect);
350-
/* copy over to change values in code */
351-
ctx->sfx_code = (char *)malloc(ctx->sfx_size);
352-
memcpy (ctx->sfx_code, decruncher_effect, ctx->sfx_size);
353-
354-
/* setup jmp target after decompression */
355-
ctx->sfx_code[DALI_EFFECT_SFX_ADDR + 0] = ctx->sfx_addr & 0xff;
356-
ctx->sfx_code[DALI_EFFECT_SFX_ADDR + 1] = (ctx->sfx_addr >> 8) & 0xff;
357-
358-
/* setup decompression destination */
359-
ctx->sfx_code[DALI_EFFECT_DST + 0] = ctx->cbm_orig_addr & 0xff;
360-
ctx->sfx_code[DALI_EFFECT_DST + 1] = (ctx->cbm_orig_addr >> 8) & 0xff;
361-
362-
/* setup compressed data src */
363-
ctx->sfx_code[DALI_EFFECT_SRC + 0] = (0x10000 - ctx->reencoded_index) & 0xff;
364-
ctx->sfx_code[DALI_EFFECT_SRC + 1] = ((0x10000 - ctx->reencoded_index) >> 8) & 0xff;
365-
366-
/* setup compressed data end */
367-
ctx->sfx_code[DALI_EFFECT_DATA_END + 0] = (0x801 + ctx->sfx_size - 2 + ctx->reencoded_index - 0x100) & 0xff;
368-
ctx->sfx_code[DALI_EFFECT_DATA_END + 1] = ((0x801 + ctx->sfx_size - 2 + ctx->reencoded_index - 0x100) >> 8) & 0xff;
369-
370-
ctx->sfx_code[DALI_EFFECT_DATA_SIZE_HI] = 0xff - (((ctx->reencoded_index + 0x100) >> 8) & 0xff);
349+
if (ctx->sfx_effect) {
350+
ctx->sfx_size = sizeof(decruncher_small_effect);
351+
/* copy over to change values in code */
352+
ctx->sfx_code = (unsigned char *)malloc(ctx->sfx_size);
353+
memcpy (ctx->sfx_code, decruncher_small_effect, ctx->sfx_size);
354+
} else {
355+
ctx->sfx_size = sizeof(decruncher_small);
356+
/* copy over to change values in code */
357+
ctx->sfx_code = (unsigned char *)malloc(ctx->sfx_size);
358+
memcpy (ctx->sfx_code, decruncher_small, ctx->sfx_size);
359+
}
371360
} else {
372-
ctx->sfx_size = sizeof(decruncher);
373-
/* copy over to change values in code */
374-
ctx->sfx_code = (char *)malloc(ctx->sfx_size);
375-
memcpy (ctx->sfx_code, decruncher, ctx->sfx_size);
361+
if (ctx->sfx_effect) {
362+
ctx->sfx_size = sizeof(decruncher_effect);
363+
/* copy over to change values in code */
364+
ctx->sfx_code = (unsigned char *)malloc(ctx->sfx_size);
365+
memcpy (ctx->sfx_code, decruncher_effect, ctx->sfx_size);
366+
} else {
367+
ctx->sfx_size = sizeof(decruncher);
368+
/* copy over to change values in code */
369+
ctx->sfx_code = (unsigned char *)malloc(ctx->sfx_size);
370+
memcpy (ctx->sfx_code, decruncher, ctx->sfx_size);
371+
}
372+
}
373+
ctx->sfx_size -= DALI_VARS_SIZE;
374+
375+
/* fetch vars from binary */
376+
377+
var_dali_sfx_src = ctx->sfx_size + 0;
378+
var_dali_src = ctx->sfx_size + 2;
379+
var_dali_dst = ctx->sfx_size + 4;
380+
var_dali_sfx_addr = ctx->sfx_size + 6;
381+
var_dali_data_end = ctx->sfx_size + 8;
382+
var_dali_data_size_hi = ctx->sfx_size + 10;
383+
var_dali_01 = ctx->sfx_size + 12;
384+
var_dali_cli = ctx->sfx_size + 14;
385+
//var_dali_effect_code = ctx->sfx_size + 16;
386+
387+
dali_sfx_src = get_var(ctx, var_dali_sfx_src);
388+
dali_src = get_var(ctx, var_dali_src);
389+
dali_dst = get_var(ctx, var_dali_dst);
390+
dali_sfx_addr = get_var(ctx, var_dali_sfx_addr);
391+
dali_data_end = get_var(ctx, var_dali_data_end);
392+
dali_data_size_hi = get_var(ctx, var_dali_data_size_hi);
393+
dali_01 = get_var(ctx, var_dali_01);
394+
dali_cli = get_var(ctx, var_dali_cli);
395+
//dali_effect_code = get_var(ctx, var_dali_effect_code);
396+
397+
/* setup jmp target after decompression */
398+
ctx->sfx_code[dali_sfx_addr + 0] = ctx->sfx_addr & 0xff;
399+
ctx->sfx_code[dali_sfx_addr + 1] = (ctx->sfx_addr >> 8) & 0xff;
400+
401+
/* setup decompression destination */
402+
ctx->sfx_code[dali_dst + 0] = ctx->cbm_orig_addr & 0xff;
403+
ctx->sfx_code[dali_dst + 1] = (ctx->cbm_orig_addr >> 8) & 0xff;
404+
405+
/* setup compressed data src */
406+
ctx->sfx_code[dali_src + 0] = (0x10000 - ctx->reencoded_index) & 0xff;
407+
ctx->sfx_code[dali_src + 1] = ((0x10000 - ctx->reencoded_index) >> 8) & 0xff;
408+
409+
/* setup compressed data end */
410+
ctx->sfx_code[dali_data_end + 0] = (0x801 + ctx->sfx_size - 2 + ctx->reencoded_index - 0x100) & 0xff;
411+
ctx->sfx_code[dali_data_end + 1] = ((0x801 + ctx->sfx_size - 2 + ctx->reencoded_index - 0x100) >> 8) & 0xff;
412+
413+
ctx->sfx_code[dali_data_size_hi] = 0xff - (((ctx->reencoded_index + 0x100) >> 8) & 0xff);
376414

415+
if (ctx->sfx_small) {
416+
if (ctx->sfx_effect) {
417+
} else {
418+
}
419+
} else {
377420
if (ctx->sfx_01 < 0) ctx->sfx_01 = 0x37;
378-
379-
/* setup jmp target after decompression */
380-
ctx->sfx_code[DALI_FAST_SFX_ADDR + 0] = ctx->sfx_addr & 0xff;
381-
ctx->sfx_code[DALI_FAST_SFX_ADDR + 1] = (ctx->sfx_addr >> 8) & 0xff;
382-
383-
/* setup decompression destination */
384-
ctx->sfx_code[DALI_FAST_DST + 0] = ctx->cbm_orig_addr & 0xff;
385-
ctx->sfx_code[DALI_FAST_DST + 1] = (ctx->cbm_orig_addr >> 8) & 0xff;
386-
387-
/* setup compressed data src */
388-
ctx->sfx_code[DALI_FAST_SRC + 0] = (0x10000 - ctx->reencoded_index) & 0xff;
389-
ctx->sfx_code[DALI_FAST_SRC + 1] = ((0x10000 - ctx->reencoded_index) >> 8) & 0xff;
390-
391-
/* setup compressed data end */
392-
ctx->sfx_code[DALI_FAST_DATA_END + 0] = (0x801 + ctx->sfx_size - 2 + ctx->reencoded_index - 0x100) & 0xff;
393-
ctx->sfx_code[DALI_FAST_DATA_END + 1] = ((0x801 + ctx->sfx_size - 2 + ctx->reencoded_index - 0x100) >> 8) & 0xff;
394-
395-
ctx->sfx_code[DALI_FAST_DATA_SIZE_HI] = 0xff - (((ctx->reencoded_index + 0x100) >> 8) & 0xff);
396-
397-
ctx->sfx_code[DALI_FAST_01] = ctx->sfx_01;
398-
if (ctx->sfx_cli) ctx->sfx_code[DALI_FAST_CLI] = 0x58;
421+
ctx->sfx_code[dali_01] = ctx->sfx_01;
422+
if (ctx->sfx_cli) ctx->sfx_code[dali_cli] = 0x58;
423+
if (ctx->sfx_effect) {
424+
} else {
425+
}
399426
}
427+
400428
printf("original: $%04x-$%04x ($%04x) 100%%\n", (int)ctx->cbm_orig_addr, (int)ctx->cbm_orig_addr + (int)ctx->unpacked_size, (int)ctx->unpacked_size);
401429
if (ctx->cbm_relocate_sfx_addr >= 0) {
402430
printf("packed: $%04x-$%04x ($%04x) %3.2f%%\n", ctx->cbm_relocate_sfx_addr, ctx->cbm_relocate_sfx_addr + (int)ctx->sfx_size + (int)ctx->packed_index, (int)ctx->sfx_size + (int)ctx->packed_index, ((float)(ctx->packed_index + (int)ctx->sfx_size) / (float)(ctx->unpacked_size) * 100.0));
403431
if (ctx->sfx_small) {
404-
ctx->sfx_code[DALI_SMALL_SFX_SRC + 0] = (ctx->cbm_relocate_sfx_addr + 0xd) & 255;
405-
ctx->sfx_code[DALI_SMALL_SFX_SRC + 1] = (ctx->cbm_relocate_sfx_addr + 0xd) >> 8;
406-
ctx->sfx_code[DALI_SMALL_DATA_END + 0] = (ctx->cbm_relocate_sfx_addr + ctx->sfx_size - 2 + ctx->reencoded_index - 0x100 - 0x0c) & 0xff;
407-
ctx->sfx_code[DALI_SMALL_DATA_END + 1] = ((ctx->cbm_relocate_sfx_addr + ctx->sfx_size - 2 + ctx->reencoded_index - 0x100 - 0x0c) >> 8) & 0xff;
408-
} else if (ctx->sfx_effect) {
409-
ctx->sfx_code[DALI_EFFECT_SFX_SRC + 0] = (ctx->cbm_relocate_sfx_addr + 0xd) & 255;
410-
ctx->sfx_code[DALI_EFFECT_SFX_SRC + 1] = (ctx->cbm_relocate_sfx_addr + 0xd) >> 8;
411-
ctx->sfx_code[DALI_EFFECT_DATA_END + 0] = (ctx->cbm_relocate_sfx_addr + ctx->sfx_size - 2 + ctx->reencoded_index - 0x100 - 0x0c) & 0xff;
412-
ctx->sfx_code[DALI_EFFECT_DATA_END + 1] = ((ctx->cbm_relocate_sfx_addr + ctx->sfx_size - 2 + ctx->reencoded_index - 0x100 - 0x0c) >> 8) & 0xff;
432+
ctx->sfx_code[dali_sfx_src + 0] = (ctx->cbm_relocate_sfx_addr + 0xd) & 255;
433+
ctx->sfx_code[dali_sfx_src + 1] = (ctx->cbm_relocate_sfx_addr + 0xd) >> 8;
434+
ctx->sfx_code[dali_data_end + 0] = (ctx->cbm_relocate_sfx_addr + ctx->sfx_size - 2 + ctx->reencoded_index - 0x100 - 0x0c) & 0xff;
435+
ctx->sfx_code[dali_data_end + 1] = ((ctx->cbm_relocate_sfx_addr + ctx->sfx_size - 2 + ctx->reencoded_index - 0x100 - 0x0c) >> 8) & 0xff;
413436
} else {
414-
ctx->sfx_code[DALI_FAST_SFX_SRC + 0] = (ctx->cbm_relocate_sfx_addr + 0x13) & 255;
415-
ctx->sfx_code[DALI_FAST_SFX_SRC + 1] = (ctx->cbm_relocate_sfx_addr + 0x13) >> 8;
416-
ctx->sfx_code[DALI_FAST_DATA_END + 0] = (ctx->cbm_relocate_sfx_addr + ctx->sfx_size - 2 + ctx->reencoded_index - 0x100 - 0x0c) & 0xff;
417-
ctx->sfx_code[DALI_FAST_DATA_END + 1] = ((ctx->cbm_relocate_sfx_addr + ctx->sfx_size - 2 + ctx->reencoded_index - 0x100 - 0x0c) >> 8) & 0xff;
437+
ctx->sfx_code[dali_sfx_src + 0] = (ctx->cbm_relocate_sfx_addr + 0x13) & 255;
438+
ctx->sfx_code[dali_sfx_src + 1] = (ctx->cbm_relocate_sfx_addr + 0x13) >> 8;
439+
ctx->sfx_code[dali_data_end + 0] = (ctx->cbm_relocate_sfx_addr + ctx->sfx_size - 2 + ctx->reencoded_index - 0x100 - 0x0c) & 0xff;
440+
ctx->sfx_code[dali_data_end + 1] = ((ctx->cbm_relocate_sfx_addr + ctx->sfx_size - 2 + ctx->reencoded_index - 0x100 - 0x0c) >> 8) & 0xff;
418441
}
419442
fputc(ctx->cbm_relocate_sfx_addr & 255, fp);
420443
fputc(ctx->cbm_relocate_sfx_addr >> 8, fp);
@@ -766,7 +789,7 @@ int main(int argc, char *argv[]) {
766789
}
767790
}
768791

769-
printf("dali v0.3.4 - a zx0-reencoder for bitfire by Tobias Bindhammer\n");
792+
printf("dali v0.3.5 - a zx0-reencoder for bitfire by Tobias Bindhammer\n");
770793
printf("underlying zx0-packer salvador by Emmanuel Marty\n");
771794

772795
if (argc == 1) {
@@ -776,7 +799,7 @@ int main(int argc, char *argv[]) {
776799
" --01 [num] Set 01 to [num] after sfx.\n"
777800
" --cli [num] Do a CLI after sfx, default is SEI.\n"
778801
" --small Use a very small depacker that fits into zeropage, but --01 and --cli are ignored and it trashes zeropage (!)\n"
779-
" --effect Use a very small depacker that fits into zeropage, but --01 and --cli are ignored and it trashes zeropage (!), a decrunch effect is applied\n"
802+
" --effect A decrunch effect is applied\n"
780803
" --no-inplace Disable inplace-decompression.\n"
781804
" --binfile Input file is a raw binary without load-address.\n"
782805
" --from [num] Compress file from [num] on.\n"

packer/dali/sfx.asm

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,34 +28,6 @@
2828
BITS_LEFT = 1
2929

3030
.depacker_dst = $01
31-
.smc_offsetd = .depacker_dst - (.dali_code_end - .dali_code_start)
32-
!ifdef SFX_FAST {
33-
DALI_FAST_SFX_SRC = sfx_src - .dali_code_start + 2
34-
DALI_FAST_SRC = lz_src - .smc_offsetd + 2
35-
DALI_FAST_DST = lz_dst - .smc_offsetd + 2
36-
DALI_FAST_SFX_ADDR = lz_sfx_addr - .smc_offsetd + 2
37-
DALI_FAST_DATA_END = lz_data_end - .smc_offsetd + 2
38-
DALI_FAST_DATA_SIZE_HI = lz_data_size_hi - .smc_offsetd + 2
39-
DALI_FAST_01 = lz_01 - .smc_offsetd + 2
40-
DALI_FAST_CLI = lz_cli - .smc_offsetd + 2
41-
}
42-
!ifdef SFX_SMALL {
43-
DALI_SMALL_SFX_SRC = sfx_src - .dali_code_start + 2
44-
DALI_SMALL_SRC = lz_src - .smc_offsetd + 2
45-
DALI_SMALL_DST = lz_dst - .smc_offsetd + 2
46-
DALI_SMALL_SFX_ADDR = lz_sfx_addr - .smc_offsetd + 2
47-
DALI_SMALL_DATA_END = lz_data_end - .smc_offsetd + 2
48-
DALI_SMALL_DATA_SIZE_HI = lz_data_size_hi - .smc_offsetd + 2
49-
}
50-
!ifdef SFX_EFFECT {
51-
DALI_EFFECT_SFX_SRC = sfx_src - .dali_code_start + 2
52-
DALI_EFFECT_SRC = lz_src - .smc_offsetd + 2
53-
DALI_EFFECT_DST = lz_dst - .smc_offsetd + 2
54-
DALI_EFFECT_SFX_ADDR = lz_sfx_addr - .smc_offsetd + 2
55-
DALI_EFFECT_DATA_END = lz_data_end - .smc_offsetd + 2
56-
DALI_EFFECT_DATA_SIZE_HI= lz_data_size_hi - .smc_offsetd + 2
57-
DALI_EFFECT_CODE = lz_effect - .smc_offsetd + 2
58-
}
5931

6032
!macro get_lz_bit {
6133
!if BITS_LEFT = 1 {
@@ -395,3 +367,37 @@ lz_sfx_addr = * + 1
395367
!warn "sfx size: ", * - .dali_code_start
396368
}
397369
.second_pass
370+
371+
.smc_offsetd = .depacker_dst - (.dali_code_end - .dali_code_start)
372+
.vars_start
373+
!word sfx_src - .dali_code_start + 2
374+
!word lz_src - .smc_offsetd + 2
375+
!word lz_dst - .smc_offsetd + 2
376+
!word lz_sfx_addr - .smc_offsetd + 2
377+
!word lz_data_end - .smc_offsetd + 2
378+
!word lz_data_size_hi - .smc_offsetd + 2
379+
!ifdef SFX_FAST {
380+
!word lz_01 - .smc_offsetd + 2
381+
!word lz_cli - .smc_offsetd + 2
382+
} else {
383+
!word $0000
384+
!word $0000
385+
}
386+
!ifdef SFX_EFFECT {
387+
!word lz_effect - .smc_offsetd + 2
388+
} else {
389+
!word $0000
390+
}
391+
.vars_end
392+
393+
;DALI_VARS_SIZE = .vars_end - .vars_start
394+
;DALI_VARS = .vars_start - .dali_code_start
395+
;DALI_SFX_SRC = DALI_VARS + 0
396+
;DALI_SRC = DALI_VARS + 2
397+
;DALI_DST = DALI_VARS + 4
398+
;DALI_SFX_ADDR = DALI_VARS + 6
399+
;DALI_DATA_END = DALI_VARS + 8
400+
;DALI_DATA_SIZE_HI = DALI_VARS + 10
401+
;DALI_01 = DALI_VARS + 12
402+
;DALI_CLI = DALI_VARS + 14
403+
;DALI_EFFECT_CODE = DALI_VARS + 16

0 commit comments

Comments
 (0)