├── exomizer ├── decruncher │ ├── data.s │ ├── data.bin │ ├── exodecrunch.s │ ├── exostreamdecr1.s │ ├── exostreamdecr2.s │ ├── Makefile │ ├── main.s │ ├── main1.s │ └── main2.s ├── changelog.txt ├── linux │ ├── exobasic │ └── exomizer ├── src │ ├── exo_main.c │ ├── optimal.c │ ├── Makefile │ ├── getflag.h │ ├── bprg_actions.h │ ├── chunkpool.h │ ├── sfx.h │ ├── membuf.h │ ├── optimal.h │ ├── radix.h │ ├── vec.h │ ├── chunkpool.c │ ├── output.h │ ├── bprg.h │ ├── match.h │ ├── vec.c │ ├── bprg_link_patch.c │ ├── search.h │ ├── membuf.c │ ├── getflag.c │ └── log.h ├── dos │ ├── exobasic.exe │ └── exomizer.exe ├── exomizer115.txt ├── win32 │ ├── exobasic.exe │ └── exomizer.exe └── exobasic10b2.txt ├── exomizer2 ├── exodecrs │ ├── data.s │ ├── dataf.s │ ├── streamdata.s │ ├── data.bin │ ├── exodecrunch.s │ ├── exostreamdecr1.s │ ├── exostreamdecr2.s │ ├── dasm │ │ ├── exodecrunch.s │ │ └── wrap.s │ ├── Makefile │ ├── mainf.s │ ├── main.s │ ├── main1.s │ ├── main2.s │ └── testrun.c ├── changelog.txt ├── exo20info.txt ├── src │ ├── optimal.c │ ├── common.h │ ├── desfx.h │ ├── b2membuf.c │ ├── getflag.h │ ├── membuf_io.h │ ├── bprg_actions.h │ ├── int.h │ ├── callback.h │ ├── pc.h │ ├── progress.h │ ├── chunkpool.h │ ├── named_buffer.h │ ├── expr.h │ ├── exo_util.h │ ├── 6502emu.h │ ├── desfx.c │ ├── exodec.h │ ├── membuf_io.c │ ├── radix.h │ ├── optimal.h │ ├── Makefile │ ├── output.h │ ├── map.h │ ├── progress.c │ ├── membuf.h │ ├── pc.c │ ├── bprg.h │ ├── named_buffer.c │ ├── match.h │ ├── vec.h │ ├── search.h │ ├── chunkpool.c │ ├── exo_helper.h │ ├── bprg_link_patch.c │ ├── expr.c │ ├── getflag.c │ ├── asm.tab.h │ └── log.h ├── dos │ ├── exobasic.exe │ └── exomizer.exe ├── rawdecrs │ ├── test1.bin │ ├── z80 │ │ ├── readme.txt │ │ ├── deexo_simple_b.asm │ │ ├── deexo_simple.asm │ │ ├── deexo_b.asm │ │ └── deexo.asm │ ├── main2.c │ ├── main.c │ ├── Makefile │ ├── exodecr.h │ ├── exodecrunch.h │ └── exodecr.c ├── win32 │ ├── exobasic.exe │ └── exomizer.exe └── exobasic10b2.txt └── README.md /exomizer/decruncher/data.s: -------------------------------------------------------------------------------- 1 | .export end_of_data 2 | .incbin "data.exo" 3 | end_of_data: 4 | -------------------------------------------------------------------------------- /exomizer2/exodecrs/data.s: -------------------------------------------------------------------------------- 1 | .export end_of_data 2 | .incbin "data.exo", 2 3 | end_of_data: 4 | -------------------------------------------------------------------------------- /exomizer2/exodecrs/dataf.s: -------------------------------------------------------------------------------- 1 | .export start_of_data 2 | start_of_data: 3 | .incbin "dataf.exo",2 4 | -------------------------------------------------------------------------------- /exomizer/changelog.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitshifters/exomizer/HEAD/exomizer/changelog.txt -------------------------------------------------------------------------------- /exomizer/linux/exobasic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitshifters/exomizer/HEAD/exomizer/linux/exobasic -------------------------------------------------------------------------------- /exomizer/linux/exomizer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitshifters/exomizer/HEAD/exomizer/linux/exomizer -------------------------------------------------------------------------------- /exomizer/src/exo_main.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitshifters/exomizer/HEAD/exomizer/src/exo_main.c -------------------------------------------------------------------------------- /exomizer/src/optimal.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitshifters/exomizer/HEAD/exomizer/src/optimal.c -------------------------------------------------------------------------------- /exomizer2/changelog.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitshifters/exomizer/HEAD/exomizer2/changelog.txt -------------------------------------------------------------------------------- /exomizer2/exo20info.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitshifters/exomizer/HEAD/exomizer2/exo20info.txt -------------------------------------------------------------------------------- /exomizer2/exodecrs/streamdata.s: -------------------------------------------------------------------------------- 1 | .export end_of_data 2 | .incbin "streamdata.exo" 3 | end_of_data: 4 | -------------------------------------------------------------------------------- /exomizer2/src/optimal.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitshifters/exomizer/HEAD/exomizer2/src/optimal.c -------------------------------------------------------------------------------- /exomizer/dos/exobasic.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitshifters/exomizer/HEAD/exomizer/dos/exobasic.exe -------------------------------------------------------------------------------- /exomizer/dos/exomizer.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitshifters/exomizer/HEAD/exomizer/dos/exomizer.exe -------------------------------------------------------------------------------- /exomizer/exomizer115.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitshifters/exomizer/HEAD/exomizer/exomizer115.txt -------------------------------------------------------------------------------- /exomizer2/dos/exobasic.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitshifters/exomizer/HEAD/exomizer2/dos/exobasic.exe -------------------------------------------------------------------------------- /exomizer2/dos/exomizer.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitshifters/exomizer/HEAD/exomizer2/dos/exomizer.exe -------------------------------------------------------------------------------- /exomizer/decruncher/data.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitshifters/exomizer/HEAD/exomizer/decruncher/data.bin -------------------------------------------------------------------------------- /exomizer/win32/exobasic.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitshifters/exomizer/HEAD/exomizer/win32/exobasic.exe -------------------------------------------------------------------------------- /exomizer/win32/exomizer.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitshifters/exomizer/HEAD/exomizer/win32/exomizer.exe -------------------------------------------------------------------------------- /exomizer2/exodecrs/data.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitshifters/exomizer/HEAD/exomizer2/exodecrs/data.bin -------------------------------------------------------------------------------- /exomizer2/rawdecrs/test1.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitshifters/exomizer/HEAD/exomizer2/rawdecrs/test1.bin -------------------------------------------------------------------------------- /exomizer2/win32/exobasic.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitshifters/exomizer/HEAD/exomizer2/win32/exobasic.exe -------------------------------------------------------------------------------- /exomizer2/win32/exomizer.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitshifters/exomizer/HEAD/exomizer2/win32/exomizer.exe -------------------------------------------------------------------------------- /exomizer/decruncher/exodecrunch.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitshifters/exomizer/HEAD/exomizer/decruncher/exodecrunch.s -------------------------------------------------------------------------------- /exomizer2/exodecrs/exodecrunch.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitshifters/exomizer/HEAD/exomizer2/exodecrs/exodecrunch.s -------------------------------------------------------------------------------- /exomizer/decruncher/exostreamdecr1.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitshifters/exomizer/HEAD/exomizer/decruncher/exostreamdecr1.s -------------------------------------------------------------------------------- /exomizer/decruncher/exostreamdecr2.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitshifters/exomizer/HEAD/exomizer/decruncher/exostreamdecr2.s -------------------------------------------------------------------------------- /exomizer2/exodecrs/exostreamdecr1.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitshifters/exomizer/HEAD/exomizer2/exodecrs/exostreamdecr1.s -------------------------------------------------------------------------------- /exomizer2/exodecrs/exostreamdecr2.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitshifters/exomizer/HEAD/exomizer2/exodecrs/exostreamdecr2.s -------------------------------------------------------------------------------- /exomizer2/exodecrs/dasm/exodecrunch.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitshifters/exomizer/HEAD/exomizer2/exodecrs/dasm/exodecrunch.s -------------------------------------------------------------------------------- /exomizer2/exodecrs/dasm/wrap.s: -------------------------------------------------------------------------------- 1 | PROCESSOR 6502 2 | ORG $c800 3 | jsr exod_decrunch 4 | rts 5 | exod_get_crunched_byte: 6 | lda opbase + 1 7 | bne nowrap 8 | dec opbase + 2 9 | nowrap: dec opbase + 1 10 | ;; change the $ffff to point to the byte immediately following the last 11 | ;; byte of the crunched file data (mem command) 12 | opbase: lda $ffff 13 | rts 14 | ;; include the decruncher source 15 | INCLUDE exodecrunch.s 16 | -------------------------------------------------------------------------------- /exomizer2/rawdecrs/z80/readme.txt: -------------------------------------------------------------------------------- 1 | This directory contains z80-assembly decrunchers contributed by Metalbrain 2 | (metalbrain_coder@gmx.net) and improved by Antonio Villena. 3 | 4 | The decrunchers decrunches data crunched with the raw command. the 5 | deexo_b.asm and deexo_simple_b.asm decrunchers decrunches data crunched 6 | backwards (with the -b flag). 7 | 8 | The deexo_simple.asm and deexo_simple_b.asm decrunchers don't handle literal 9 | sequences and assumes that the table for bits[i] and base[i] is aligned to a 10 | 256 boundary. 11 | 12 | Please direct any questions about these decrunchers to Metalbrain. 13 | -------------------------------------------------------------------------------- /exomizer/decruncher/Makefile: -------------------------------------------------------------------------------- 1 | 2 | SOURCES = main.os exodecrunch.os data.os 3 | SOURCES1 = main1.os exostreamdecr1.os data.os 4 | SOURCES2 = main2.os exostreamdecr2.os data.os 5 | NAME = test.prg 6 | NAME1 = test1.prg 7 | NAME2 = test2.prg 8 | 9 | 10 | build: $(NAME) $(NAME1) $(NAME2) 11 | 12 | $(NAME): $(MAKEFILE) $(SOURCES) 13 | ld65 -t c64 $(SOURCES) -o $@ 14 | 15 | $(NAME1): $(MAKEFILE) $(SOURCES1) 16 | ld65 -t c64 $(SOURCES1) -o $@ 17 | 18 | $(NAME2): $(MAKEFILE) $(SOURCES2) 19 | ld65 -t c64 $(SOURCES2) -o $@ 20 | 21 | %.os: %.s 22 | ca65 $< -o $@ 23 | 24 | clean: 25 | $(RM) $(SOURCES) $(SOURCES1) $(SOURCES2) $(NAME) $(NAME1) $(NAME2) data.exo 26 | 27 | data.os: data.exo 28 | 29 | data.exo: data.bin 30 | exomizer -m 1024 data.bin,0x3000 -o data.exo 31 | -------------------------------------------------------------------------------- /exomizer/src/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for exomizer 3 | # 4 | 5 | CFLAGS = -Wall -O3 -ffast-math -mcpu=i686 -fomit-frame-pointer -fgcse -pedantic 6 | LDFLAGS = -s 7 | 8 | #CFLAGS = -g 9 | #LDFLAGS = -g 10 | 11 | SHARED_OBJS = getflag.o log.o 12 | EXO_OBJS = match.o search.o exo_main.o optimal.o output.o sfx264.o sfx64.o \ 13 | sfx64ne.o sfx264ne.o chunkpool.o radix.o 14 | BAS_OBJS = bas_main.o bprg_renumber.o bprg_link_patch.o bprg_trampoline.o \ 15 | bprg.o vec.o membuf.o 16 | ALL_OBJS = $(EXO_OBJS) $(BAS_OBJS) $(SHARED_OBJS) 17 | 18 | .PHONY: build 19 | 20 | build: $(MAKEFILE) exomizer exobasic 21 | 22 | exomizer: deps $(EXO_OBJS) $(SHARED_OBJS) 23 | $(CC) $(LDFLAGS) -o $@ $(EXO_OBJS) $(SHARED_OBJS) 24 | 25 | exobasic: deps $(BAS_OBJS) $(SHARED_OBJS) 26 | $(CC) $(LDFLAGS) -o $@ $(BAS_OBJS) $(SHARED_OBJS) 27 | 28 | clean: 29 | -$(RM) $(EXO_OBJS) $(BAS_OBJS) $(SHARED_OBJS) \ 30 | exomizer exobasic exomizer.exe exobasic.exe deps 31 | 32 | -include deps 33 | 34 | deps: $(wildcard *.h) 35 | $(CC) -MM $(wildcard *.c) >$@ 36 | -------------------------------------------------------------------------------- /exomizer2/rawdecrs/main2.c: -------------------------------------------------------------------------------- 1 | 2 | #include "exodecr.h" 3 | #include 4 | #include 5 | 6 | int main(int argc, char *argv[]) 7 | { 8 | FILE *in; 9 | FILE *out; 10 | char *inp; 11 | char *outp; 12 | char *p; 13 | int len; 14 | 15 | if(argc != 3) 16 | { 17 | fprintf(stderr, "Error: usage: %s \n", argv[0]); 18 | exit(-1); 19 | } 20 | in = fopen(argv[1], "rb"); 21 | if(in == NULL) 22 | { 23 | fprintf(stderr, "Error: can't open %s for input.\n", argv[1]); 24 | exit(-1); 25 | } 26 | out = fopen(argv[2], "wb"); 27 | if(in == NULL) 28 | { 29 | fprintf(stderr, "Error: can't open %s for output.\n", argv[2]); 30 | exit(-1); 31 | } 32 | 33 | p = malloc(500000); 34 | len = fread(p, 1, 500000, in); 35 | inp = p + len; 36 | outp = p + 500000; 37 | 38 | outp = exo_decrunch(inp, outp); 39 | 40 | fwrite(outp, 1, p + 500000 - outp, out); 41 | 42 | free(p); 43 | 44 | fclose(out); 45 | fclose(in); 46 | 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PLEASE NOTE EXOMIZER NOW HAS AN OFFICIAL HOME & BIT BUCKET SOURCE PAGE 2 | # THIS REPO IS A LEGACY ARCHIVE 3 | [Click here](https://bitbucket.org/magli143/exomizer/wiki/Home) 4 | 5 | 6 | # exomizer source code archive 7 | An archive of [Exomizer v1](http://hem.bredband.net/magli143/exo/index_old.html) and [Exomizer v2](http://hem.bredband.net/magli143/exo/index_old.html) 8 | 9 | Preserved here in github in case the old site disappeared from the web. 10 | 11 | ##Exomizer tool source code 12 | 13 | Exomizer is a program that compresses files in a way that tries to be as efficient as possible but still allows them to be decompressed in environments where CPU speed and RAM are limited. For some popular 8-bit computers using 6502 compatible CPUs it can also generate executable files that decompress themselves in memory when run. 14 | 15 | Forked into Github for reference, since no official source repo exists (yet) 16 | 17 | All credit goes to original author 18 | 19 | ## Usage - v1 20 | 21 | https://raw.githubusercontent.com/bitshifters/exomizer/master/exomizer/exomizer115.txt 22 | 23 | ## Usage - v2 24 | 25 | https://raw.githubusercontent.com/bitshifters/exomizer/master/exomizer2/exo20info.txt 26 | 27 | -------------------------------------------------------------------------------- /exomizer2/rawdecrs/main.c: -------------------------------------------------------------------------------- 1 | 2 | #include "exodecrunch.h" 3 | #include 4 | #include 5 | 6 | static int read_byte(void *read_data) 7 | { 8 | FILE *in; 9 | int c; 10 | 11 | in = (FILE*)read_data; 12 | c = fgetc(in); 13 | 14 | return c; 15 | } 16 | 17 | int main(int argc, char *argv[]) 18 | { 19 | FILE *in; 20 | FILE *out; 21 | struct exo_decrunch_ctx *ctx; 22 | int c; 23 | 24 | if(argc != 3) 25 | { 26 | fprintf(stderr, "Error: usage: %s \n", argv[0]); 27 | exit(-1); 28 | } 29 | in = fopen(argv[1], "rb"); 30 | if(in == NULL) 31 | { 32 | fprintf(stderr, "Error: can't open %s for input.\n", argv[1]); 33 | exit(-1); 34 | } 35 | out = fopen(argv[2], "wb"); 36 | if(in == NULL) 37 | { 38 | fprintf(stderr, "Error: can't open %s for output.\n", argv[2]); 39 | exit(-1); 40 | } 41 | 42 | ctx = exo_decrunch_new(MAX_OFFSET, read_byte, in); 43 | 44 | while((c = exo_read_decrunched_byte(ctx)) != EOF) 45 | { 46 | fputc(c, out); 47 | } 48 | 49 | exo_decrunch_delete(ctx); 50 | 51 | fclose(out); 52 | fclose(in); 53 | 54 | return 0; 55 | } 56 | -------------------------------------------------------------------------------- /exomizer2/rawdecrs/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for exomizer decruncher 3 | # 4 | 5 | #CFLAGS = -Wall -O3 -ffast-math -mtune=i686 -fomit-frame-pointer -fgcse -pedantic 6 | #LDFLAGS = -s 7 | 8 | CFLAGS = -g -mtune=i686 -Wall 9 | LDFLAGS = -g -mtune=i686 10 | 11 | TEST_OBJS = main.o exodecrunch.o 12 | TEST2_OBJS = main2.o exodecr.o 13 | 14 | #.SILENT: 15 | 16 | .PHONY: build 17 | 18 | build: $(MAKEFILE) test test2 19 | 20 | test: main test1.exo test2.exo test3.exo 21 | ./main test1.exo test1.dec 22 | cmp -l test1.bin test1.dec 23 | ./main test2.exo test2.dec 24 | cmp -l test2.bin test2.dec 25 | ./main test3.exo test3.dec 26 | cmp -l test3.bin test3.dec 27 | 28 | test2: main2 test1.oxe test2.oxe test3.oxe 29 | ./main2 test1.oxe test1.dec 30 | cmp -l test1.bin test1.dec 31 | ./main2 test2.oxe test2.dec 32 | cmp -l test2.bin test2.dec 33 | ./main2 test3.oxe test3.dec 34 | cmp -l test3.bin test3.dec 35 | 36 | main: deps $(TEST_OBJS) 37 | $(CC) $(LDFLAGS) -o $@ $(TEST_OBJS) 38 | 39 | main2: deps $(TEST2_OBJS) 40 | $(CC) $(LDFLAGS) -o $@ $(TEST2_OBJS) 41 | 42 | clean: 43 | -$(RM) $(TEST_OBJS) $(TEST2_OBJS) main main.exe main2 main2.exe \ 44 | *.o deps *.exo *.oxe *.dec 45 | 46 | -include deps 47 | 48 | deps: $(wildcard *.h) 49 | $(CC) -MM $(wildcard *.c) >$@ 50 | 51 | %.exo: %.bin 52 | ../src/exomizer raw $< -o $@ 53 | 54 | %.oxe: %.bin 55 | ../src/exomizer raw -b $< -o $@ 56 | -------------------------------------------------------------------------------- /exomizer2/src/common.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_CB 2 | #define ALREADY_INCLUDED_CB 3 | 4 | /* 5 | * Copyright (c) 2005 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | typedef int cb_cmp(const void *a, const void *b); 32 | typedef void cb_free(void *a); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /exomizer2/src/desfx.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_DESFX 2 | #define ALREADY_INCLUDED_DESFX 3 | 4 | /* 5 | * Copyright (c) 2007 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | #include "int.h" 32 | 33 | u16 decrunch_sfx(u8 mem[65536], u16 run, u16 *start, u16 *end); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /exomizer2/rawdecrs/exodecr.h: -------------------------------------------------------------------------------- 1 | #ifndef EXO_DECR_ALREADY_INCLUDED 2 | #define EXO_DECR_ALREADY_INCLUDED 3 | 4 | /* 5 | * Copyright (c) 2005 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software for any purpose, 12 | * including commercial applications, and to alter it and redistribute it 13 | * freely, subject to the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented * you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | */ 29 | 30 | char *exo_decrunch(const char *in, char *out); 31 | 32 | #endif /* EXO_DECRUNCH_ALREADY_INCLUDED */ 33 | -------------------------------------------------------------------------------- /exomizer2/src/b2membuf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void generate(const char *name, FILE *in, FILE *out) 5 | { 6 | char buf[12]; 7 | char *glue = ""; 8 | int len; 9 | int size = 0; 10 | 11 | fprintf(out, "static unsigned char %s_arr[] = {\n", name); 12 | while((len = fread(buf, 1, 12, in)) > 0) 13 | { 14 | int col; 15 | 16 | size += len; 17 | fprintf(out, " "); 18 | for(col = 0; col < len; ++col) 19 | { 20 | fprintf(out, "%s0x%02x", glue, (unsigned char)buf[col]); 21 | glue = ","; 22 | } 23 | fprintf(out, "\n"); 24 | } 25 | fprintf(out, "};\n"); 26 | fprintf(out, "struct membuf %s[1] = {{%s_arr, %d, %d}};\n", 27 | name, name, size, size); 28 | } 29 | 30 | int main(int argc, char *argv[]) 31 | { 32 | int i; 33 | if(argc < 2) 34 | { 35 | fprintf(stderr, "Error: must give at least one input file.\n"); 36 | } 37 | 38 | fprintf(stdout, "#include \"membuf.h\"\n"); 39 | for(i = 1; i < argc; ++i) 40 | { 41 | FILE *in = fopen(argv[i], "rb"); 42 | if(in == NULL) 43 | { 44 | fprintf(stderr, "Error: can't open file \"%s\" for input.\n", 45 | argv[i]); 46 | exit(-1); 47 | } 48 | generate(argv[i], in, stdout); 49 | fclose(in); 50 | } 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /exomizer2/src/getflag.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_GETFLAG 2 | #define ALREADY_INCLUDED_GETFLAG 3 | /* 4 | * Copyright (c) 2002, 2003 Magnus Lind. 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from 8 | * the use of this software. 9 | * 10 | * Permission is granted to anyone to use this software, alter it and re- 11 | * distribute it freely for any non-commercial, non-profit purpose subject to 12 | * the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not 15 | * claim that you wrote the original software. If you use this software in a 16 | * product, an acknowledgment in the product documentation would be 17 | * appreciated but is not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not 20 | * be misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any distribution. 23 | * 24 | * 4. The names of this software and/or it's copyright holders may not be 25 | * used to endorse or promote products derived from this software without 26 | * specific prior written permission. 27 | * 28 | */ 29 | 30 | extern int flagind; 31 | extern int flagflag; 32 | extern const char *flagarg; 33 | 34 | int getflag(int argc, char *argv[], const char *flags); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /exomizer2/src/membuf_io.h: -------------------------------------------------------------------------------- 1 | #ifndef MEMBUF_IO_ALREADY_INCLUDED 2 | #define MEMBUF_IO_ALREADY_INCLUDED 3 | 4 | /* 5 | * Copyright (c) 2005 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | #include "membuf.h" 32 | void read_file(const char *name, struct membuf *buf); 33 | void write_file(const char *name, struct membuf *buf); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /exomizer/src/getflag.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_GETFLAG_H 2 | #define ALREADY_INCLUDED_GETFLAG_H 3 | /* 4 | * Copyright (c) 2002, 2003 Magnus Lind. 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from 8 | * the use of this software. 9 | * 10 | * Permission is granted to anyone to use this software, alter it and re- 11 | * distribute it freely for any non-commercial, non-profit purpose subject to 12 | * the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not 15 | * claim that you wrote the original software. If you use this software in a 16 | * product, an acknowledgment in the product documentation would be 17 | * appreciated but is not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not 20 | * be misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any distribution. 23 | * 24 | * 4. The names of this software and/or it's copyright holders may not be 25 | * used to endorse or promote products derived from this software without 26 | * specific prior written permission. 27 | * 28 | */ 29 | 30 | extern int flagind; 31 | extern int flagflag; 32 | extern const char *flagarg; 33 | 34 | int getflag(int argc, char *argv[], const char *flags); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /exomizer2/src/bprg_actions.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_BPRG_ACTIONS 2 | #define ALREADY_INCLUDED_BPRG_ACTIONS 3 | 4 | /* 5 | * Copyright (c) 2003 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | #include "bprg.h" 32 | 33 | void 34 | bprg_renumber(struct bprg_ctx *ctx); 35 | 36 | void 37 | bprg_link_patch(struct bprg_ctx *ctx); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /exomizer/src/bprg_actions.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_BPRG_ACTIONS_H 2 | #define ALREADY_INCLUDED_BPRG_ACTIONS_H 3 | 4 | /* 5 | * Copyright (c) 2003 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | #include "bprg.h" 32 | 33 | void 34 | bprg_renumber(struct bprg_ctx *ctx); 35 | 36 | void 37 | bprg_link_patch(struct bprg_ctx *ctx); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /exomizer2/src/int.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_INT 2 | #define INCLUDED_INT 3 | 4 | /* 5 | * Copyright (c) 2005 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | typedef signed char i8; 32 | typedef signed short int i16; 33 | typedef signed int i32; 34 | 35 | typedef unsigned char u8; 36 | typedef unsigned short int u16; 37 | typedef unsigned int u32; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /exomizer2/src/callback.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_CALLBACK 2 | #define ALREADY_INCLUDED_CALLBACK 3 | 4 | /* 5 | * Copyright (c) 2005 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | #include 32 | 33 | typedef int cb_cmp(const void *a, const void *b); 34 | typedef void cb_free(void *a); 35 | typedef void cb_fprint(FILE *f, const void *a); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /exomizer2/src/pc.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_PC 2 | #define ALREADY_INCLUDED_PC 3 | 4 | /* 5 | * Copyright (c) 2004 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | #include "expr.h" 32 | 33 | void pc_dump(int level); 34 | void pc_set(int pc); 35 | void pc_set_expr(struct expr *pc); 36 | struct expr *pc_get(void); 37 | void pc_add(int offset); 38 | void pc_add_expr(struct expr *pc); 39 | void pc_unset(void); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /exomizer2/src/progress.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_PROGRESS 2 | #define ALREADY_INCLUDED_PROGRESS 3 | 4 | /* 5 | * Copyright (c) 2005 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | struct progress 32 | { 33 | char *msg; 34 | float factor; 35 | int offset; 36 | int last; 37 | }; 38 | 39 | void progress_init(struct progress p[1], char *msg, int start, int end); 40 | 41 | void progress_bump(struct progress p[1], int pos); 42 | 43 | void progress_free(struct progress p[1]); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /exomizer/src/chunkpool.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_CHUNKPOOL_H 2 | #define ALREADY_INCLUDED_CHUNKPOOL_H 3 | 4 | /* 5 | * Copyright (c) 2003 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | struct chunkpool { 32 | int chunk_size; 33 | int chunk; 34 | int chunk_pos; 35 | int chunk_max; 36 | void *chunks[32]; 37 | }; 38 | 39 | void 40 | chunkpool_init(struct chunkpool *ctx, int size); 41 | 42 | void 43 | chunkpool_free(struct chunkpool *ctx); 44 | 45 | void * 46 | chunkpool_malloc(struct chunkpool *ctx); 47 | 48 | void * 49 | chunkpool_calloc(struct chunkpool *ctx); 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /exomizer2/rawdecrs/exodecrunch.h: -------------------------------------------------------------------------------- 1 | #ifndef EXO_DECRUNCH_ALREADY_INCLUDED 2 | #define EXO_DECRUNCH_ALREADY_INCLUDED 3 | 4 | /* 5 | * Copyright (c) 2005 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software for any purpose, 12 | * including commercial applications, and to alter it and redistribute it 13 | * freely, subject to the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented * you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | */ 29 | 30 | #define MAX_OFFSET 65535 31 | 32 | typedef int exo_read_crunched_byte(void *data); 33 | 34 | struct exo_decrunch_ctx * 35 | exo_decrunch_new(unsigned short int max_offset, 36 | exo_read_crunched_byte *read_byte, 37 | void *read_data); 38 | 39 | int 40 | exo_read_decrunched_byte(struct exo_decrunch_ctx *ctx); 41 | 42 | void 43 | exo_decrunch_delete(struct exo_decrunch_ctx *ctx); 44 | 45 | #endif /* EXO_DECRUNCH_ALREADY_INCLUDED */ 46 | -------------------------------------------------------------------------------- /exomizer2/src/chunkpool.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_CHUNKPOOL 2 | #define ALREADY_INCLUDED_CHUNKPOOL 3 | 4 | /* 5 | * Copyright (c) 2003 - 2005, 2015 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | #include "callback.h" 32 | #include "vec.h" 33 | 34 | struct chunkpool { 35 | int item_size; 36 | int item_pos; 37 | int item_end; 38 | void *current_chunk; 39 | struct vec used_chunks; 40 | }; 41 | 42 | void 43 | chunkpool_init(struct chunkpool *ctx, int item_size); 44 | 45 | void 46 | chunkpool_free(struct chunkpool *ctx); 47 | 48 | void 49 | chunkpool_free2(struct chunkpool *ctx, cb_free *f); 50 | 51 | void * 52 | chunkpool_malloc(struct chunkpool *ctx); 53 | 54 | void * 55 | chunkpool_calloc(struct chunkpool *ctx); 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /exomizer2/src/named_buffer.h: -------------------------------------------------------------------------------- 1 | #ifndef NAMED_BUFFER_INCLUDED 2 | #define NAMED_BUFFER_INCLUDED 3 | 4 | /* 5 | * Copyright (c) 2005 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | #include "membuf.h" 32 | #include "chunkpool.h" 33 | #include "map.h" 34 | 35 | struct named_buffer { 36 | struct map map; 37 | struct chunkpool buf; 38 | }; 39 | 40 | void named_buffer_init(struct named_buffer *nb); 41 | void named_buffer_free(struct named_buffer *nb); 42 | void named_buffer_clear(struct named_buffer *nb); 43 | 44 | void named_buffer_copy(struct named_buffer *nb, 45 | const struct named_buffer *source); 46 | 47 | struct membuf *new_named_buffer(struct named_buffer *nb, const char *name); 48 | struct membuf *get_named_buffer(struct named_buffer *nb, const char *name); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /exomizer2/src/expr.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_EXPR 2 | #define ALREADY_INCLUDED_EXPR 3 | 4 | /* 5 | * Copyright (c) 2005 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | #include "int.h" 32 | #include "asm.tab.h" 33 | 34 | union expr_type 35 | { 36 | i32 number; 37 | const char *symref; 38 | struct expr *arg1; 39 | }; 40 | 41 | struct expr 42 | { 43 | union expr_type type; 44 | struct expr *expr_arg2; 45 | i16 expr_op; 46 | }; 47 | 48 | void expr_init(void); 49 | void expr_free(void); 50 | 51 | struct expr *new_expr_op1(i16 op, struct expr *arg); 52 | struct expr *new_expr_op2(i16 op, struct expr *arg1, struct expr *arg2); 53 | struct expr *new_expr_symref(const char *symbol); 54 | struct expr *new_expr_number(i32 number); 55 | void expr_dump(int level, struct expr *e); 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /exomizer/src/sfx.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_SFX_H 2 | #define ALREADY_INCLUDED_SFX_H 3 | 4 | /* 5 | * Copyright (c) 2002, 2003 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | #include "output.h" 32 | typedef 33 | void sfx1_set_new_load_f(output_ctx out, /* IN/OUT */ 34 | unsigned short int load); /* IN */ 35 | 36 | typedef 37 | void sfx2_add_stages_f(output_ctx out, /* IN/OUT */ 38 | unsigned short int start); /* IN */ 39 | struct sfx_decruncher { 40 | sfx1_set_new_load_f *load; 41 | sfx2_add_stages_f *stages; 42 | const char *text; 43 | }; 44 | extern struct sfx_decruncher sfx_c64[]; 45 | extern struct sfx_decruncher sfx_c64ne[]; 46 | extern struct sfx_decruncher sfx_c264[]; 47 | extern struct sfx_decruncher sfx_c264ne[]; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /exomizer2/exodecrs/Makefile: -------------------------------------------------------------------------------- 1 | 2 | WFLAGS = -Wall -Wstrict-prototypes 3 | CFLAGS = $(WFLAGS) -O3 -ffast-math -mtune=i686 -fomit-frame-pointer -fgcse -pedantic 4 | LDFLAGS = -s 5 | 6 | #CFLAGS = -g -mtune=i686 $(WFLAGS) 7 | #LDFLAGS = -g -mtune=i686 8 | 9 | TEST_OBJS = testrun.o ../src/6502emu.o ../src/exo_util.o ../src/log.o 10 | 11 | SOURCES = main.os exodecrunch.os data.os 12 | SOURCESF = mainf.os krilldecr.os dataf.os 13 | SOURCES1 = main1.os exostreamdecr1.os streamdata.os 14 | SOURCES2 = main2.os exostreamdecr2.os streamdata.os 15 | NAME = test.prg 16 | NAMEF = testf.prg 17 | NAME1 = test1.prg 18 | NAME2 = test2.prg 19 | 20 | 21 | build: $(NAME) $(NAMEF) $(NAME1) $(NAME2) 22 | 23 | testrun: $(TEST_OBJS) 24 | @echo "Linking $@" 25 | @$(CC) $(LDFLAGS) -o $@ $(TEST_OBJS) 26 | 27 | $(NAME): $(MAKEFILE) testrun $(SOURCES) 28 | ld65 -t c64 $(SOURCES) -o $@ 29 | ./testrun $@ data.bin,0x3000 30 | 31 | $(NAMEF): $(MAKEFILE) testrun $(SOURCESF) 32 | ld65 -t c64 $(SOURCESF) -o $@ 33 | ./testrun $@ data.bin,0x3000 34 | 35 | $(NAME1): $(MAKEFILE) testrun $(SOURCES1) 36 | ld65 -t c64 $(SOURCES1) -o $@ 37 | ./testrun $@ data.bin,0xEA00 38 | 39 | $(NAME2): $(MAKEFILE) testrun $(SOURCES2) 40 | ld65 -t c64 $(SOURCES2) -o $@ 41 | ./testrun $@ data.bin,0xEA00 42 | 43 | %.os: %.s 44 | ca65 $< -o $@ 45 | 46 | clean: 47 | $(RM) $(TEST_OBJS) $(SOURCES) $(SOURCESF) $(SOURCES1) $(SOURCES2) \ 48 | $(NAME) $(NAMEF) $(NAME1) $(NAME2) testrun data.exo dataf.exo \ 49 | streamdata.exo 50 | 51 | data.os: data.exo 52 | dataf.os: dataf.exo 53 | streamdata.os: streamdata.exo 54 | 55 | data.exo: data.bin 56 | ../src/exomizer mem -q data.bin,0x3000 -o data.exo 57 | 58 | dataf.exo: data.bin 59 | ../src/exomizer mem -q -f data.bin,0x3000 -o dataf.exo 60 | 61 | streamdata.exo: data.bin 62 | ../src/exomizer raw -q -b -c -m 1024 data.bin -o streamdata.exo 63 | 64 | %.o: %.c 65 | @echo "Compiling $<" 66 | @$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $< 67 | 68 | %: %.o 69 | @$(CC) $(LDFLAGS) $< -o $@ 70 | -------------------------------------------------------------------------------- /exomizer2/src/exo_util.h: -------------------------------------------------------------------------------- 1 | #ifndef EXO_UTIL_ALREADY_INCLUDED 2 | #define EXO_UTIL_ALREADY_INCLUDED 3 | 4 | /* 5 | * Copyright (c) 2008 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | #include "log.h" 32 | #include "membuf.h" 33 | 34 | /* 35 | * target is the basic token for the sys/call basic command 36 | * it may be -1 for hardcoded detection of a few targets. 37 | */ 38 | int find_sys(const unsigned char *buf, int target); 39 | 40 | struct load_info 41 | { 42 | int basic_txt_start; /* in */ 43 | int basic_var_start; /* out */ 44 | int run; /* out */ 45 | int start; /* out */ 46 | int end; /* out */ 47 | }; 48 | 49 | void load_located(char *filename, unsigned char mem[65536], 50 | struct load_info *info); 51 | 52 | int str_to_int(const char *str, int *value); 53 | 54 | const char *fixup_appl(char *appl); 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /exomizer2/src/6502emu.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_6502EMU 2 | #define ALREADY_INCLUDED_6502EMU 3 | 4 | /* 5 | * Copyright (c) 2007 - 2008 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | #include "int.h" 32 | 33 | #define MEM_ACCESS_READ(THIS,ADDR) (THIS)->read((THIS),(ADDR)) 34 | #define MEM_ACCESS_WRITE(THIS,ADDR,VALUE) (THIS)->write((THIS),(ADDR),(VALUE)) 35 | 36 | struct mem_access 37 | { 38 | void *ctx; 39 | u8 (*read)(struct mem_access *this, u16 address); 40 | void (*write)(struct mem_access *this, u16 address, u8 value); 41 | }; 42 | 43 | u16 mem_access_read_u16le(struct mem_access *this, u16 address); 44 | 45 | 46 | struct cpu_ctx 47 | { 48 | struct mem_access mem; 49 | u32 cycles; 50 | u16 pc; 51 | u8 sp; 52 | u8 flags; 53 | u8 a; 54 | u8 x; 55 | u8 y; 56 | }; 57 | 58 | void next_inst(struct cpu_ctx *r); 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /exomizer/src/membuf.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_MEMBUF_H 2 | #define ALREADY_INCLUDED_MEMBUF_H 3 | 4 | /* 5 | * Copyright (c) 2002, 2003 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | #define STATIC_MEMBUF_INIT {0, 0, 0} 32 | 33 | struct membuf { 34 | void *buf; 35 | int len; 36 | int size; 37 | }; 38 | 39 | void membuf_init(struct membuf *sb); 40 | void membuf_clear(struct membuf *sb); 41 | void membuf_free(struct membuf *sb); 42 | void membuf_new(struct membuf **sbp); 43 | void membuf_delete(struct membuf **sbp); 44 | int membuf_memlen(struct membuf *sb); 45 | void *membuf_memcpy(struct membuf *sb, const void *mem, int memlen); 46 | void *membuf_append(struct membuf *sb, const void *mem, int memlen); 47 | void membuf_atleast(struct membuf *sb, int size); 48 | void membuf_atmost(struct membuf *sb, int size); 49 | int membuf_get_size(struct membuf *sb); 50 | void *membuf_get(struct membuf *sb); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /exomizer2/src/desfx.c: -------------------------------------------------------------------------------- 1 | 2 | #include "desfx.h" 3 | #include "6502emu.h" 4 | #include "log.h" 5 | 6 | static void mem_access_write(struct mem_access *this, u16 address, u8 value) 7 | { 8 | u8 *mem = this->ctx; 9 | mem[address] = value; 10 | } 11 | 12 | static u8 mem_access_read(struct mem_access *this, u16 address) 13 | { 14 | u8 *mem = this->ctx; 15 | return mem[address]; 16 | } 17 | 18 | u16 decrunch_sfx(u8 mem[65536], u16 run, u16 *startp, u16 *endp) 19 | { 20 | struct cpu_ctx r; 21 | u16 start; 22 | u16 end; 23 | r.cycles = 0; 24 | r.mem.ctx = mem; 25 | r.mem.read = mem_access_read; 26 | r.mem.write = mem_access_write; 27 | r.pc = run; 28 | r.sp = '\xf6'; 29 | r.flags = 0; 30 | 31 | LOG(LOG_DEBUG, ("run %04x\n", run)); 32 | 33 | /* setting up decrunch */ 34 | while(r.pc >= 0x0400 || r.sp != 0xf6) 35 | { 36 | next_inst(&r); 37 | } 38 | end = mem_access_read_u16le(&r.mem, 0xfe); 39 | 40 | LOG(LOG_DEBUG, ("end %04x @%u\n", end, r.cycles)); 41 | hex_dump(LOG_DEBUG, mem + 0x334, 156); 42 | 43 | /* decrunching */ 44 | while(r.pc < 0x400) 45 | { 46 | /* is this an absolute sta, stx or sty to the IO-area? */ 47 | int op_code = MEM_ACCESS_READ(&r.mem, r.pc); 48 | int addr = mem_access_read_u16le(&r.mem, r.pc + 1); 49 | 50 | if((op_code == 0x8d || op_code == 0x8e || op_code == 0x8c) && 51 | addr >= 0xd000 && addr < 0xe000) 52 | { 53 | /* ignore it, its probably an effect */ 54 | LOG(LOG_DEBUG, ("ignoring sta/stx/sty to IO %02x $%04X\n", 55 | op_code, addr)); 56 | r.pc += 3; 57 | } 58 | 59 | next_inst(&r); 60 | } 61 | start = mem_access_read_u16le(&r.mem, 0xfe); 62 | LOG(LOG_DEBUG, ("start %04x @%u\n", start, r.cycles)); 63 | 64 | if(startp != NULL) 65 | { 66 | *startp = start; 67 | } 68 | if(endp != NULL) 69 | { 70 | *endp = end; 71 | } 72 | return r.pc; 73 | } 74 | -------------------------------------------------------------------------------- /exomizer2/src/exodec.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_EXODEC 2 | #define ALREADY_INCLUDED_EXODEC 3 | 4 | /* 5 | * Copyright (c) 2005 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | #include "membuf.h" 32 | 33 | struct dec_table 34 | { 35 | unsigned char table_bit[3]; 36 | unsigned char table_off[3]; 37 | unsigned char table_bi[100]; 38 | unsigned char table_lo[100]; 39 | unsigned char table_hi[100]; 40 | }; 41 | 42 | struct dec_ctx 43 | { 44 | int inpos; 45 | int inend; 46 | unsigned char *inbuf; 47 | struct membuf *outbuf; 48 | unsigned int bitbuf; 49 | /* dep_table */ 50 | struct dec_table t[1]; 51 | int bits_read; 52 | }; 53 | 54 | /* returns the encoding */ 55 | char * 56 | dec_ctx_init(struct dec_ctx ctx[1], 57 | struct membuf *inbuf, struct membuf *outbuf); 58 | 59 | void 60 | dec_ctx_free(struct dec_ctx ctx[1]); 61 | 62 | void dec_ctx_decrunch(struct dec_ctx ctx[1]); 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /exomizer/src/optimal.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_OPTIMAL_H 2 | #define ALREADY_INCLUDED_OPTIMAL_H 3 | 4 | /* 5 | * Copyright (c) 2002, 2003 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | #include "search.h" 32 | #include "output.h" 33 | 34 | float optimal_encode(const_matchp mp, /* IN */ 35 | encode_match_data emp); /* IN */ 36 | 37 | void optimal_init(encode_match_data emp); /* IN/OUT */ 38 | 39 | void optimal_free(encode_match_data emd); /* IN */ 40 | 41 | void optimal_optimize(encode_match_data emd, /* IN/OUT */ 42 | matchp_enum_get_next_f * f, /* IN */ 43 | void *priv); /* IN */ 44 | 45 | void optimal_fixup(encode_match_data emd, /* IN/OUT */ 46 | int max_len, /* IN */ 47 | int max_offset); /* IN */ 48 | 49 | void optimal_dump(encode_match_data emp); /* IN */ 50 | 51 | void optimal_out(output_ctx out, /* IN/OUT */ 52 | encode_match_data emd); /* IN */ 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /exomizer2/src/membuf_io.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005 Magnus Lind. 3 | * 4 | * This software is provided 'as-is', without any express or implied warranty. 5 | * In no event will the authors be held liable for any damages arising from 6 | * the use of this software. 7 | * 8 | * Permission is granted to anyone to use this software, alter it and re- 9 | * distribute it freely for any non-commercial, non-profit purpose subject to 10 | * the following restrictions: 11 | * 12 | * 1. The origin of this software must not be misrepresented; you must not 13 | * claim that you wrote the original software. If you use this software in a 14 | * product, an acknowledgment in the product documentation would be 15 | * appreciated but is not required. 16 | * 17 | * 2. Altered source versions must be plainly marked as such, and must not 18 | * be misrepresented as being the original software. 19 | * 20 | * 3. This notice may not be removed or altered from any distribution. 21 | * 22 | * 4. The names of this software and/or it's copyright holders may not be 23 | * used to endorse or promote products derived from this software without 24 | * specific prior written permission. 25 | * 26 | */ 27 | 28 | #include "membuf_io.h" 29 | #include "log.h" 30 | #include 31 | #include 32 | 33 | void read_file(const char *name, struct membuf *buf) 34 | { 35 | char block[1024]; 36 | FILE *in; 37 | int len; 38 | 39 | in = fopen(name, "rb"); 40 | if(in == NULL) 41 | { 42 | LOG(LOG_ERROR, ("Can't open file \"%s\" for input.\n", name)); 43 | exit(-1); 44 | } 45 | do 46 | { 47 | len = fread(block, 1, 1024, in); 48 | membuf_append(buf, block, len); 49 | } 50 | while(len == 1024); 51 | LOG(LOG_DEBUG, ("read %d bytes from file\n", len)); 52 | fclose(in); 53 | } 54 | 55 | void write_file(const char *name, struct membuf *buf) 56 | { 57 | FILE *out; 58 | out = fopen(name, "wb"); 59 | if(out == NULL) 60 | { 61 | LOG(LOG_ERROR, ("Can't open file \"%s\" for output.\n", name)); 62 | exit(-1); 63 | } 64 | fwrite(membuf_get(buf), 1, membuf_memlen(buf), out); 65 | fclose(out); 66 | } 67 | -------------------------------------------------------------------------------- /exomizer/src/radix.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_RADIX_H 2 | #define ALREADY_INCLUDED_RADIX_H 3 | /* 4 | * Copyright (c) 2002, 2003 Magnus Lind. 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from 8 | * the use of this software. 9 | * 10 | * Permission is granted to anyone to use this software, alter it and re- 11 | * distribute it freely for any non-commercial, non-profit purpose subject to 12 | * the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not 15 | * claim that you wrote the original software. If you use this software in a 16 | * product, an acknowledgment in the product documentation would be 17 | * appreciated but is not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not 20 | * be misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any distribution. 23 | * 24 | * 4. The names of this software and/or it's copyright holders may not be 25 | * used to endorse or promote products derived from this software without 26 | * specific prior written permission. 27 | * 28 | */ 29 | 30 | #include "chunkpool.h" 31 | 32 | typedef struct _radix_node *radix_nodep; 33 | 34 | struct _radix_root { 35 | int depth; 36 | radix_nodep root; 37 | struct chunkpool mem[1]; 38 | }; 39 | 40 | typedef struct _radix_root radix_root[1]; 41 | typedef struct _radix_root *radix_rootp; 42 | 43 | 44 | typedef void free_callback(void *data, void *priv); 45 | 46 | /* *f will be called even for null pointers */ 47 | void radix_tree_free(radix_root rr, /* IN */ 48 | free_callback * f, /* IN */ 49 | void *priv); /* IN */ 50 | 51 | void radix_tree_init(radix_root rr); /* IN */ 52 | 53 | void radix_node_set(radix_root rr, /* IN */ 54 | unsigned int index, /* IN */ 55 | void *data); /* IN */ 56 | 57 | void *radix_node_get(radix_root rr, /* IN */ 58 | unsigned int index); /* IN */ 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /exomizer2/src/radix.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_RADIX 2 | #define ALREADY_INCLUDED_RADIX 3 | /* 4 | * Copyright (c) 2002, 2003 Magnus Lind. 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from 8 | * the use of this software. 9 | * 10 | * Permission is granted to anyone to use this software, alter it and re- 11 | * distribute it freely for any non-commercial, non-profit purpose subject to 12 | * the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not 15 | * claim that you wrote the original software. If you use this software in a 16 | * product, an acknowledgment in the product documentation would be 17 | * appreciated but is not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not 20 | * be misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any distribution. 23 | * 24 | * 4. The names of this software and/or it's copyright holders may not be 25 | * used to endorse or promote products derived from this software without 26 | * specific prior written permission. 27 | * 28 | */ 29 | 30 | #include "chunkpool.h" 31 | 32 | typedef struct _radix_node *radix_nodep; 33 | 34 | struct _radix_root { 35 | int depth; 36 | radix_nodep root; 37 | struct chunkpool mem[1]; 38 | }; 39 | 40 | typedef struct _radix_root radix_root[1]; 41 | typedef struct _radix_root *radix_rootp; 42 | 43 | 44 | typedef void free_callback(void *data, void *priv); 45 | 46 | /* *f will be called even for null pointers */ 47 | void radix_tree_free(radix_root rr, /* IN */ 48 | free_callback * f, /* IN */ 49 | void *priv); /* IN */ 50 | 51 | void radix_tree_init(radix_root rr); /* IN */ 52 | 53 | void radix_node_set(radix_root rr, /* IN */ 54 | unsigned int index, /* IN */ 55 | void *data); /* IN */ 56 | 57 | void *radix_node_get(radix_root rr, /* IN */ 58 | unsigned int index); /* IN */ 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /exomizer/src/vec.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_VEC_H 2 | #define ALREADY_INCLUDED_VEC_H 3 | 4 | /* 5 | * Copyright (c) 2003 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | #include 32 | #include "membuf.h" 33 | 34 | #define STATIC_VEC_INIT(EL_SIZE) {(EL_SIZE), STATIC_MEMBUF_INIT} 35 | 36 | struct vec { 37 | size_t elsize; 38 | struct membuf buf; 39 | }; 40 | 41 | struct vec_iterator { 42 | struct vec *vec; 43 | int pos; 44 | }; 45 | 46 | typedef int cb_cmp(const void *a, const void *b); 47 | typedef int cb_free(void *a); 48 | 49 | void vec_init(struct vec *p, size_t elsize); 50 | void vec_clear(struct vec *p, cb_free * f); 51 | void vec_free(struct vec *p, cb_free * f); 52 | 53 | int vec_count(struct vec *p); 54 | void *vec_get(struct vec *p, int index); 55 | void *vec_push(struct vec *p, const void *in); 56 | 57 | void *vec_find(struct vec *p, cb_cmp * f, const void *key); 58 | int vec_insert_uniq(struct vec *p, cb_cmp * f, const void *in, void **out); 59 | 60 | void vec_get_iterator(struct vec *p, struct vec_iterator *i); 61 | void *vec_iterator_next(struct vec_iterator *i); 62 | 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /exomizer2/src/optimal.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_OPTIMAL 2 | #define ALREADY_INCLUDED_OPTIMAL 3 | 4 | /* 5 | * Copyright (c) 2002 - 2005 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | #include "search.h" 32 | #include "output.h" 33 | 34 | float optimal_encode(const_matchp mp, /* IN */ 35 | encode_match_data emp); /* IN */ 36 | 37 | void optimal_init(encode_match_data emp); /* IN/OUT */ 38 | 39 | void optimal_free(encode_match_data emd); /* IN */ 40 | 41 | void optimal_optimize(encode_match_data emd, /* IN/OUT */ 42 | matchp_enum_get_next_f * f, /* IN */ 43 | void *priv); /* IN */ 44 | 45 | void optimal_encoding_import(encode_match_data emd, /* IN/OUT */ 46 | const char *encoding); /* IN */ 47 | 48 | const char * 49 | optimal_encoding_export(encode_match_data emd); /* IN */ 50 | 51 | void optimal_dump(int level, encode_match_data emp); /* IN */ 52 | 53 | void optimal_out(output_ctx out, /* IN/OUT */ 54 | encode_match_data emd); /* IN */ 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /exomizer2/src/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for exomizer 3 | # 4 | WFLAGS = -Wall -Wstrict-prototypes 5 | CFLAGS = $(WFLAGS) -O3 -ffast-math -mtune=i686 -fomit-frame-pointer -fgcse -pedantic 6 | LDFLAGS = -s 7 | 8 | #CFLAGS = -g -mtune=i686 $(WFLAGS) 9 | #LDFLAGS = -g -mtune=i686 10 | 11 | SHARED_OBJS = getflag.o log.o membuf.o 12 | RAW_OBJS = match.o search.o exo_raw.o optimal.o output.o membuf_io.o \ 13 | chunkpool.o radix.o exo_helper.o exodec.o progress.o exo_util.o \ 14 | vec.o 15 | EXO_OBJS = match.o search.o exo_main.o optimal.o output.o membuf_io.o \ 16 | chunkpool.o radix.o exo_helper.o exodec.o progress.o asm.tab.o \ 17 | lex.yy.o parse.o expr.o pc.o vec.o named_buffer.o map.o desfx.o \ 18 | 6502emu.o exo_util.o sfxdecr.o 19 | BAS_OBJS = bas_main.o bprg_renumber.o bprg_link_patch.o bprg_trampoline.o \ 20 | bprg.o vec.o 21 | ALL_OBJS = $(EXO_OBJS) $(RAW_OBJS) $(BAS_OBJS) $(SHARED_OBJS) 22 | 23 | #.SILENT: 24 | 25 | .PHONY: build clean 26 | 27 | build: $(MAKEFILE) exomizer exoraw exobasic 28 | 29 | exomizer: deps $(EXO_OBJS) $(SHARED_OBJS) 30 | @echo "Linking $@" 31 | @$(CC) $(LDFLAGS) -o $@ $(EXO_OBJS) $(SHARED_OBJS) 32 | 33 | exoraw: deps $(RAW_OBJS) $(SHARED_OBJS) 34 | @echo "Linking $@" 35 | @$(CC) $(LDFLAGS) -o $@ $(RAW_OBJS) $(SHARED_OBJS) 36 | 37 | exobasic: deps $(BAS_OBJS) $(SHARED_OBJS) 38 | @echo "Linking $@" 39 | @$(CC) $(LDFLAGS) -o $@ $(BAS_OBJS) $(SHARED_OBJS) 40 | 41 | clean: 42 | @echo "Cleaning project" 43 | -@$(RM) $(EXO_OBJS) $(RAW_OBJS) $(BAS_OBJS) $(SHARED_OBJS) 44 | -@$(RM) b2membuf.o b2membuf b2membuf.exe sfxdecr sfxdecr.c deps 45 | -@$(RM) exomizer exoraw exobasic exomizer.exe exoraw.exe exobasic.exe 46 | 47 | 48 | asm.tab.h asm.tab.c: asm.y 49 | bison -t -d asm.y 50 | 51 | lex.yy.c: asm.yy 52 | flex -B asm.yy 53 | 54 | sfxdecr.c: sfxdecr b2membuf 55 | @./b2membuf sfxdecr >sfxdecr.c 56 | 57 | sfxdecr: sfxdecr.s exoraw 58 | @echo "Compressing $<" 59 | @./exoraw -q sfxdecr.s -o sfxdecr 60 | 61 | -include deps 62 | 63 | deps: $(wildcard *.h) asm.tab.h 64 | @echo "Generating dependencies" 65 | @$(CC) -MM $(wildcard *.c) >$@ 66 | 67 | %.o: %.c 68 | @echo "Compiling $<" 69 | @$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $< 70 | 71 | %: %.o 72 | @$(CC) $(LDFLAGS) $< -o $@ 73 | -------------------------------------------------------------------------------- /exomizer2/src/output.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_OUTPUT 2 | #define ALREADY_INCLUDED_OUTPUT 3 | 4 | /* 5 | * Copyright (c) 2002 - 2005 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | #include "membuf.h" 32 | #include 33 | 34 | struct _output_ctx { 35 | unsigned int bitbuf; 36 | int pos; 37 | int start; 38 | struct membuf *buf; 39 | }; 40 | 41 | typedef struct _output_ctx output_ctx[1]; 42 | typedef struct _output_ctx *output_ctxp; 43 | 44 | void output_ctx_init(output_ctx ctx, struct membuf *out); /* IN/OUT */ 45 | 46 | unsigned int output_get_pos(output_ctx ctx); /* IN */ 47 | 48 | void output_byte(output_ctx ctx, /* IN/OUT */ 49 | unsigned char byte); /* IN */ 50 | 51 | void output_word(output_ctx ctx, /* IN/OUT */ 52 | unsigned short int word); /* IN */ 53 | 54 | void output_bits_flush(output_ctx ctx); /* IN/OUT */ 55 | 56 | void output_bits(output_ctx ctx, /* IN/OUT */ 57 | int count, /* IN */ 58 | int val); /* IN */ 59 | 60 | void output_gamma_code(output_ctx ctx, /* IN/OUT */ 61 | int code); /* IN */ 62 | #endif 63 | -------------------------------------------------------------------------------- /exomizer2/src/map.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_MAP 2 | #define ALREADY_INCLUDED_MAP 3 | 4 | /* 5 | * Copyright (c) 2006 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | #include "vec.h" 32 | #include "callback.h" 33 | 34 | struct map_entry { 35 | const char *key; 36 | void *value; 37 | }; 38 | 39 | #define STATIC_MAP_INIT {STATIC_VEC_INIT(sizeof(struct map_entry))} 40 | 41 | struct map { 42 | struct vec vec; 43 | }; 44 | 45 | struct map_iterator { 46 | struct vec_iterator vec; 47 | }; 48 | 49 | void map_init(struct map *m); 50 | void map_clear(struct map *m); 51 | void map_free(struct map *m); 52 | 53 | void *map_put(struct map *m, const char *key, void *value); 54 | void *map_get(const struct map *m, const char *key); 55 | int map_contains_key(const struct map *m, const char *key); 56 | void map_put_all(struct map *m, const struct map *source); 57 | 58 | int map_contains(const struct map *m1, const struct map *m2, cb_cmp *f); 59 | 60 | /** 61 | * If f is NULL, only the keys will be compared. 62 | * returns -1 on error, 1 on equality and 0 otherwise, 63 | **/ 64 | int map_equals(const struct map *m1, const struct map *m2, cb_cmp *f); 65 | 66 | void map_get_iterator(const struct map *p, struct map_iterator *i); 67 | const struct map_entry *map_iterator_next(struct map_iterator *i); 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /exomizer2/src/progress.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005 Magnus Lind. 3 | * 4 | * This software is provided 'as-is', without any express or implied warranty. 5 | * In no event will the authors be held liable for any damages arising from 6 | * the use of this software. 7 | * 8 | * Permission is granted to anyone to use this software, alter it and re- 9 | * distribute it freely for any non-commercial, non-profit purpose subject to 10 | * the following restrictions: 11 | * 12 | * 1. The origin of this software must not be misrepresented; you must not 13 | * claim that you wrote the original software. If you use this software in a 14 | * product, an acknowledgment in the product documentation would be 15 | * appreciated but is not required. 16 | * 17 | * 2. Altered source versions must be plainly marked as such, and must not 18 | * be misrepresented as being the original software. 19 | * 20 | * 3. This notice may not be removed or altered from any distribution. 21 | * 22 | * 4. The names of this software and/or it's copyright holders may not be 23 | * used to endorse or promote products derived from this software without 24 | * specific prior written permission. 25 | * 26 | */ 27 | 28 | #include "progress.h" 29 | #include "log.h" 30 | #include 31 | 32 | #define BAR_LENGTH 64 33 | 34 | void progress_init(struct progress p[1], char *msg, int start, int end) 35 | { 36 | if(start > end) 37 | { 38 | p->factor = (float)BAR_LENGTH / (end - start); 39 | p->offset = -start; 40 | } 41 | else 42 | { 43 | p->factor = (float)BAR_LENGTH / (start - end); 44 | p->offset = start; 45 | } 46 | p->last = -1; 47 | if(msg == NULL) 48 | { 49 | msg = "progressing_"; 50 | } 51 | p->msg = msg; 52 | 53 | LOG(LOG_DEBUG, ("start %d, end %d, pfactor %f, poffset %d\n", 54 | start, end, p->factor, p->offset)); 55 | } 56 | 57 | void progress_bump(struct progress p[1], int pos) 58 | { 59 | int fraction = ((pos + p->offset) * p->factor) + 0.5; 60 | while(fraction > p->last) 61 | { 62 | if(p->last == -1) 63 | { 64 | LOG(LOG_NORMAL, (" %*s]\r [", BAR_LENGTH, "")); 65 | } 66 | else 67 | { 68 | LOG(LOG_NORMAL, ("%c", p->msg[p->last % strlen(p->msg)])); 69 | } 70 | p->last += 1; 71 | } 72 | } 73 | 74 | void progress_free(struct progress p[1]) 75 | { 76 | } 77 | -------------------------------------------------------------------------------- /exomizer2/src/membuf.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_MEMBUF 2 | #define ALREADY_INCLUDED_MEMBUF 3 | 4 | /* 5 | * Copyright (c) 2002 - 2005 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | #define STATIC_MEMBUF_INIT {0, 0, 0} 32 | 33 | struct membuf { 34 | void *buf; 35 | int len; 36 | int size; 37 | }; 38 | 39 | void membuf_init(struct membuf *sb); 40 | void membuf_clear(struct membuf *sb); 41 | void membuf_free(struct membuf *sb); 42 | void membuf_new(struct membuf **sbp); 43 | void membuf_delete(struct membuf **sbp); 44 | /* Gets the length of data put into the membuf */ 45 | int membuf_memlen(const struct membuf *sb); 46 | void membuf_truncate(struct membuf *sb, int len); 47 | 48 | /* returns the new len or < 0 if failure */ 49 | int membuf_trim(struct membuf *sb, int pos); 50 | 51 | void *membuf_memcpy(struct membuf *sb, int offset, const void *mem, int len); 52 | void *membuf_append(struct membuf *sb, const void *mem, int len); 53 | void *membuf_append_char(struct membuf *sb, char c); 54 | void *membuf_insert(struct membuf *sb, int offset, const void *mem, int len); 55 | void membuf_remove(struct membuf *sb, int offset, int len); 56 | /* Grows the capacity if it's less than the given size */ 57 | void membuf_atleast(struct membuf *sb, int size); 58 | /* Skrinks the capacity if it's greater than the given size */ 59 | void membuf_atmost(struct membuf *sb, int size); 60 | /* Gets the current capacity of the membuf */ 61 | int membuf_get_size(const struct membuf *sb); 62 | /* Gets a pointer to the internal buffer. Don't dereferece it beyond 63 | * its size. */ 64 | void *membuf_get(const struct membuf *sb); 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /exomizer/exobasic10b2.txt: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | Features of the Exobasic 1.0b2 tool: 3 | ------------------------------------------------------------------------------- 4 | 5 | 1) Renumber the basic lines (standard), -n, (Beta quality) 6 | 7 | The lines are renumbered starting with and increasing with for each 8 | line. 9 | 10 | 2) Renumber the basic lines (extreme), -N (Beta quality) 11 | 12 | This will increase the file crunchability. This renumbering will renumber 13 | many basic lines to 0. Yes, they will run correctly. :) 14 | 15 | 2) Clobber the line links, -p (Release quality) 16 | 17 | Normally a basic program file consists of a linked list of zero terminated 18 | basic line strings. The links between the lines are redundant and can be 19 | recreated. In fact the basic interpreter always recreate the links when 20 | a basic program is loaded from the READY prompt. This is done to be able to 21 | easily move basic programs between compatible platforms where the start 22 | address of basic differs. The links contained in the file are only correct if 23 | the file is loaded to the address it was saved from. 24 | 25 | This means that we can write any values as the links as long as we recreate 26 | them before running the program. The routine that recreates the links is at 27 | $A533 (c64) or $8818 (c16/plus4). 28 | 29 | The values this option actually writes to the links are optimized to increase 30 | the file crunchability. 31 | 32 | 3) Add a trampoline -t, (Release quality) 33 | 34 | This feature adds a small machine language routine at the beginning of the 35 | program. This routine does all the startup preparation work necessary and 36 | then starts the program. If the "clobber line links" option is selected, the 37 | added trampoline will recreate them. When a trampoline is added it is very 38 | easy to crunch the file and then just jmp the trampoline to start it. For a 39 | c16/plus4 trampoline add a -4 option to the commandline as well. 40 | 41 | 4) Remove rem statements and unnecessary spaces, -r (Release quality) 42 | 43 | This feature removes rem statements unless they are first on a line and the 44 | line is a goto/gosub target. If so then only the rem statement is left. 45 | It also removes unneccessary spaces between basic statements. 46 | 47 | 5) Regenerate c16/plus4 stack color table, -c (Release quality) 48 | This feature only works if a c16/plus4 trampoline is created with the -t and 49 | -4 flags. It will regenerate a system color table located at the hardware 50 | stack that the Exomisers built-in decruncher overwrites. 51 | 52 | ------------------------------------------------------------------------------- 53 | -------------------------------------------------------------------------------- /exomizer2/exobasic10b2.txt: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | Features of the Exobasic 1.0b2 tool: 3 | ------------------------------------------------------------------------------- 4 | 5 | 1) Renumber the basic lines (standard), -n, (Beta quality) 6 | 7 | The lines are renumbered starting with and increasing with for each 8 | line. 9 | 10 | 2) Renumber the basic lines (extreme), -N (Beta quality) 11 | 12 | This will increase the file crunchability. This renumbering will renumber 13 | many basic lines to 0. Yes, they will run correctly. :) 14 | 15 | 2) Clobber the line links, -p (Release quality) 16 | 17 | Normally a basic program file consists of a linked list of zero terminated 18 | basic line strings. The links between the lines are redundant and can be 19 | recreated. In fact the basic interpreter always recreate the links when 20 | a basic program is loaded from the READY prompt. This is done to be able to 21 | easily move basic programs between compatible platforms where the start 22 | address of basic differs. The links contained in the file are only correct if 23 | the file is loaded to the address it was saved from. 24 | 25 | This means that we can write any values as the links as long as we recreate 26 | them before running the program. The routine that recreates the links is at 27 | $A533 (c64) or $8818 (c16/plus4). 28 | 29 | The values this option actually writes to the links are optimized to increase 30 | the file crunchability. 31 | 32 | 3) Add a trampoline -t, (Release quality) 33 | 34 | This feature adds a small machine language routine at the beginning of the 35 | program. This routine does all the startup preparation work necessary and 36 | then starts the program. If the "clobber line links" option is selected, the 37 | added trampoline will recreate them. When a trampoline is added it is very 38 | easy to crunch the file and then just jmp the trampoline to start it. For a 39 | c16/plus4 trampoline add a -4 option to the commandline as well. 40 | 41 | 4) Remove rem statements and unnecessary spaces, -r (Release quality) 42 | 43 | This feature removes rem statements unless they are first on a line and the 44 | line is a goto/gosub target. If so then only the rem statement is left. 45 | It also removes unneccessary spaces between basic statements. 46 | 47 | 5) Regenerate c16/plus4 stack color table, -c (Release quality) 48 | This feature only works if a c16/plus4 trampoline is created with the -t and 49 | -4 flags. It will regenerate a system color table located at the hardware 50 | stack that the Exomisers built-in decruncher overwrites. 51 | 52 | ------------------------------------------------------------------------------- 53 | -------------------------------------------------------------------------------- /exomizer/src/chunkpool.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003 Magnus Lind. 3 | * 4 | * This software is provided 'as-is', without any express or implied warranty. 5 | * In no event will the authors be held liable for any damages arising from 6 | * the use of this software. 7 | * 8 | * Permission is granted to anyone to use this software, alter it and re- 9 | * distribute it freely for any non-commercial, non-profit purpose subject to 10 | * the following restrictions: 11 | * 12 | * 1. The origin of this software must not be misrepresented; you must not 13 | * claim that you wrote the original software. If you use this software in a 14 | * product, an acknowledgment in the product documentation would be 15 | * appreciated but is not required. 16 | * 17 | * 2. Altered source versions must be plainly marked as such, and must not 18 | * be misrepresented as being the original software. 19 | * 20 | * 3. This notice may not be removed or altered from any distribution. 21 | * 22 | * 4. The names of this software and/or it's copyright holders may not be 23 | * used to endorse or promote products derived from this software without 24 | * specific prior written permission. 25 | * 26 | */ 27 | 28 | #include 29 | #include 30 | #include "chunkpool.h" 31 | #include "log.h" 32 | 33 | void 34 | chunkpool_init(struct chunkpool *ctx, int size) 35 | { 36 | ctx->chunk_size = size; 37 | ctx->chunk = -1; 38 | ctx->chunk_pos = 0; 39 | ctx->chunk_max = (0x1fffff / size) * size; 40 | } 41 | 42 | void 43 | chunkpool_free(struct chunkpool *ctx) 44 | { 45 | while(ctx->chunk >= 0) 46 | { 47 | free(ctx->chunks[ctx->chunk]); 48 | ctx->chunk -= 1; 49 | } 50 | ctx->chunk_pos = 0; 51 | } 52 | 53 | void * 54 | chunkpool_malloc(struct chunkpool *ctx) 55 | { 56 | void *p; 57 | if(ctx->chunk_pos == 0) 58 | { 59 | void *m; 60 | if(ctx->chunk == 31) 61 | { 62 | LOG(LOG_ERROR, ("out of chunks in file %s, line %d\n", 63 | __FILE__, __LINE__)); 64 | LOG(LOG_BRIEF, ("chunk_size %d\n", ctx->chunk_size)); 65 | LOG(LOG_BRIEF, ("chunk_max %d\n", ctx->chunk_max)); 66 | LOG(LOG_BRIEF, ("chunk %d\n", ctx->chunk)); 67 | exit(1); 68 | } 69 | m = malloc(ctx->chunk_max); 70 | if (m == NULL) 71 | { 72 | LOG(LOG_ERROR, ("out of memory error in file %s, line %d\n", 73 | __FILE__, __LINE__)); 74 | exit(1); 75 | } 76 | ctx->chunk += 1; 77 | ctx->chunks[ctx->chunk] = m; 78 | } 79 | p = (char*)ctx->chunks[ctx->chunk] + ctx->chunk_pos; 80 | ctx->chunk_pos += ctx->chunk_size; 81 | if(ctx->chunk_pos >= ctx->chunk_max) 82 | { 83 | ctx->chunk_pos = 0; 84 | } 85 | return p; 86 | } 87 | 88 | void * 89 | chunkpool_calloc(struct chunkpool *ctx) 90 | { 91 | void *p = chunkpool_malloc(ctx); 92 | memset(p, 0, ctx->chunk_size); 93 | return p; 94 | } 95 | -------------------------------------------------------------------------------- /exomizer2/src/pc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Magnus Lind. 3 | * 4 | * This software is provided 'as-is', without any express or implied warranty. 5 | * In no event will the authors be held liable for any damages arising from 6 | * the use of this software. 7 | * 8 | * Permission is granted to anyone to use this software, alter it and re- 9 | * distribute it freely for any non-commercial, non-profit purpose subject to 10 | * the following restrictions: 11 | * 12 | * 1. The origin of this software must not be misrepresented; you must not 13 | * claim that you wrote the original software. If you use this software in a 14 | * product, an acknowledgment in the product documentation would be 15 | * appreciated but is not required. 16 | * 17 | * 2. Altered source versions must be plainly marked as such, and must not 18 | * be misrepresented as being the original software. 19 | * 20 | * 3. This notice may not be removed or altered from any distribution. 21 | * 22 | * 4. The names of this software and/or it's copyright holders may not be 23 | * used to endorse or promote products derived from this software without 24 | * specific prior written permission. 25 | * 26 | */ 27 | 28 | #include "pc.h" 29 | #include "log.h" 30 | #include 31 | 32 | struct pc { 33 | struct expr *pc1; 34 | int pc2; 35 | }; 36 | 37 | static struct expr unset_value[1]; 38 | static struct pc p[1] = {{unset_value, 0}}; 39 | 40 | void pc_dump(int level) 41 | { 42 | } 43 | 44 | void pc_set(int pc) 45 | { 46 | p->pc1 = NULL; 47 | p->pc2 = pc; 48 | } 49 | 50 | void pc_set_expr(struct expr *pc) 51 | { 52 | p->pc1 = pc; 53 | p->pc2 = 0; 54 | } 55 | 56 | struct expr *pc_get(void) 57 | { 58 | struct expr *old_pc1; 59 | 60 | if(p->pc1 == unset_value) 61 | { 62 | LOG(LOG_ERROR, ("PC must be set by a .org(pc) call.\n")); 63 | exit(-1); 64 | } 65 | if(p->pc1 == NULL || p->pc2 != 0) 66 | { 67 | old_pc1 = p->pc1; 68 | p->pc1 = new_expr_number(p->pc2); 69 | p->pc2 = 0; 70 | if(old_pc1 != NULL) 71 | { 72 | p->pc1 = new_expr_op2(PLUS, p->pc1, old_pc1); 73 | } 74 | } 75 | 76 | return p->pc1; 77 | } 78 | 79 | void pc_add(int offset) 80 | { 81 | if(p->pc1 != unset_value) 82 | { 83 | p->pc2 += offset; 84 | } 85 | } 86 | 87 | void pc_add_expr(struct expr *pc) 88 | { 89 | struct expr *old_pc1; 90 | 91 | if(p->pc1 != unset_value) 92 | { 93 | old_pc1 = p->pc1; 94 | p->pc1 = pc; 95 | if(old_pc1 != NULL) 96 | { 97 | p->pc1 = new_expr_op2(PLUS, p->pc1, old_pc1); 98 | } 99 | } 100 | } 101 | 102 | void pc_unset(void) 103 | { 104 | pc_set_expr(unset_value); 105 | } 106 | -------------------------------------------------------------------------------- /exomizer/src/output.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_OUTPUT_H 2 | #define ALREADY_INCLUDED_OUTPUT_H 3 | 4 | /* 5 | * Copyright (c) 2002, 2003 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | #include 32 | 33 | struct _output_ctx { 34 | unsigned int bitbuf; 35 | unsigned short int pos; 36 | unsigned short int start; 37 | unsigned char flags; 38 | unsigned char buf[65536]; 39 | }; 40 | 41 | typedef struct _output_ctx output_ctx[1]; 42 | typedef struct _output_ctx *output_ctxp; 43 | 44 | void output_ctx_init(output_ctx ctx); /* IN/OUT */ 45 | 46 | void output_ctx_set_start(output_ctx ctx, /* IN/OUT */ 47 | unsigned int pos); /* IN */ 48 | 49 | void output_ctx_set_reverse(output_ctx ctx); /* IN/OUT */ 50 | 51 | unsigned int output_ctx_close(output_ctx ctx, /* IN */ 52 | FILE * out); /* OUT */ 53 | 54 | unsigned int output_get_pos(output_ctx ctx); /* IN */ 55 | 56 | void output_set_pos(output_ctx ctx, /* IN */ 57 | unsigned int pos); /* IN */ 58 | 59 | void output_copy_bytes(output_ctx ctx, /* IN */ 60 | unsigned int src_pos, /* IN */ 61 | unsigned int len); /* IN */ 62 | 63 | void output_byte(output_ctx ctx, /* IN/OUT */ 64 | unsigned char byte); /* IN */ 65 | 66 | void output_word(output_ctx ctx, /* IN/OUT */ 67 | unsigned short int word); /* IN */ 68 | 69 | void output_bits_flush(output_ctx ctx); /* IN/OUT */ 70 | 71 | void output_bits(output_ctx ctx, /* IN/OUT */ 72 | int count, /* IN */ 73 | int val); /* IN */ 74 | 75 | void output_gamma_code(output_ctx ctx, /* IN/OUT */ 76 | int code); /* IN */ 77 | #endif 78 | -------------------------------------------------------------------------------- /exomizer2/src/bprg.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_BPRG 2 | #define ALREADY_INCLUDED_BPRG 3 | 4 | /* 5 | * Copyright (c) 2003 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | #include "vec.h" 32 | 33 | struct bprg_ctx { 34 | unsigned short len; 35 | unsigned short start; 36 | unsigned short basic_start; 37 | unsigned char mem[65536]; 38 | }; 39 | 40 | struct bprg_iterator { 41 | const unsigned char *mem; 42 | unsigned short pos; 43 | }; 44 | 45 | typedef int cb_line_mutate(const unsigned char *in, /* IN */ 46 | unsigned char *mem, /* IN/OUT */ 47 | unsigned short *pos, /* IN/OUT */ 48 | void *priv); /* IN/OUT */ 49 | 50 | void 51 | bprg_init(struct bprg_ctx *ctx, const char *prg_name); 52 | 53 | void 54 | bprg_save(struct bprg_ctx *ctx, const char *prg_name); 55 | 56 | void 57 | bprg_free(struct bprg_ctx *ctx); 58 | 59 | void 60 | bprg_get_iterator(struct bprg_ctx *ctx, struct bprg_iterator *i); 61 | 62 | struct brow { 63 | unsigned char row[1]; 64 | }; 65 | 66 | int 67 | bprg_iterator_next(struct bprg_iterator *i, struct brow **b); 68 | 69 | void 70 | bprg_lines_mutate(struct bprg_ctx *ctx, 71 | cb_line_mutate *f, 72 | void *priv); 73 | 74 | /* higher level functions */ 75 | void 76 | bprg_renumber(struct bprg_ctx *ctx, 77 | int start, 78 | int step, 79 | int mode); 80 | 81 | void 82 | bprg_link_patch(struct bprg_ctx *ctx); 83 | 84 | void 85 | bprg_rem_remove(struct bprg_ctx *ctx); 86 | 87 | #define TRAMPOLINE_FLAG_C264 1 88 | #define TRAMPOLINE_FLAG_REGEN 2 89 | #define TRAMPOLINE_FLAG_C264_COLOR_REGEN 4 90 | 91 | void 92 | bprg_trampoline_add(struct bprg_ctx *ctx, 93 | int *start, int *var, int *end, 94 | int flags); 95 | #endif 96 | -------------------------------------------------------------------------------- /exomizer/src/bprg.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_BPRG_H 2 | #define ALREADY_INCLUDED_BPRG_H 3 | 4 | /* 5 | * Copyright (c) 2003 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | #include "vec.h" 32 | 33 | struct bprg_ctx { 34 | unsigned short len; 35 | unsigned short start; 36 | unsigned short basic_start; 37 | unsigned char mem[65536]; 38 | }; 39 | 40 | struct bprg_iterator { 41 | const unsigned char *mem; 42 | unsigned short pos; 43 | }; 44 | 45 | typedef int cb_line_mutate(const unsigned char *in, /* IN */ 46 | unsigned char *mem, /* IN/OUT */ 47 | unsigned short *pos, /* IN/OUT */ 48 | void *priv); /* IN/OUT */ 49 | 50 | void 51 | bprg_init(struct bprg_ctx *ctx, const char *prg_name); 52 | 53 | void 54 | bprg_save(struct bprg_ctx *ctx, const char *prg_name); 55 | 56 | void 57 | bprg_free(struct bprg_ctx *ctx); 58 | 59 | void 60 | bprg_get_iterator(struct bprg_ctx *ctx, struct bprg_iterator *i); 61 | 62 | struct brow { 63 | unsigned char row[1]; 64 | }; 65 | 66 | int 67 | bprg_iterator_next(struct bprg_iterator *i, struct brow **b); 68 | 69 | void 70 | bprg_lines_mutate(struct bprg_ctx *ctx, 71 | cb_line_mutate *f, 72 | void *priv); 73 | 74 | /* higher level functions */ 75 | void 76 | bprg_renumber(struct bprg_ctx *ctx, 77 | int start, 78 | int step, 79 | int mode); 80 | 81 | void 82 | bprg_link_patch(struct bprg_ctx *ctx); 83 | 84 | void 85 | bprg_rem_remove(struct bprg_ctx *ctx); 86 | 87 | #define TRAMPOLINE_FLAG_C264 1 88 | #define TRAMPOLINE_FLAG_REGEN 2 89 | #define TRAMPOLINE_FLAG_C264_COLOR_REGEN 4 90 | 91 | void 92 | bprg_trampoline_add(struct bprg_ctx *ctx, 93 | int *start, int *var, int *end, 94 | int flags); 95 | #endif 96 | -------------------------------------------------------------------------------- /exomizer2/src/named_buffer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005 Magnus Lind. 3 | * 4 | * This software is provided 'as-is', without any express or implied warranty. 5 | * In no event will the authors be held liable for any damages arising from 6 | * the use of this software. 7 | * 8 | * Permission is granted to anyone to use this software, alter it and re- 9 | * distribute it freely for any non-commercial, non-profit purpose subject to 10 | * the following restrictions: 11 | * 12 | * 1. The origin of this software must not be misrepresented; you must not 13 | * claim that you wrote the original software. If you use this software in a 14 | * product, an acknowledgment in the product documentation would be 15 | * appreciated but is not required. 16 | * 17 | * 2. Altered source versions must be plainly marked as such, and must not 18 | * be misrepresented as being the original software. 19 | * 20 | * 3. This notice may not be removed or altered from any distribution. 21 | * 22 | * 4. The names of this software and/or it's copyright holders may not be 23 | * used to endorse or promote products derived from this software without 24 | * specific prior written permission. 25 | * 26 | */ 27 | 28 | #include "named_buffer.h" 29 | #include "log.h" 30 | #include "chunkpool.h" 31 | #include "membuf_io.h" 32 | 33 | #include 34 | 35 | void named_buffer_init(struct named_buffer *nb) 36 | { 37 | map_init(&nb->map); 38 | chunkpool_init(&nb->buf, sizeof(struct membuf)); 39 | } 40 | 41 | void named_buffer_free(struct named_buffer *nb) 42 | { 43 | typedef void cb_free(void *a); 44 | 45 | chunkpool_free2(&nb->buf, (cb_free*)membuf_free); 46 | map_free(&nb->map); 47 | } 48 | 49 | void named_buffer_clear(struct named_buffer *nb) 50 | { 51 | named_buffer_free(nb); 52 | named_buffer_init(nb); 53 | } 54 | 55 | void named_buffer_copy(struct named_buffer *nb, 56 | const struct named_buffer *source) 57 | { 58 | struct map_iterator i[1]; 59 | const struct map_entry *e; 60 | 61 | for(map_get_iterator(&source->map, i); (e = map_iterator_next(i)) != NULL;) 62 | { 63 | /* don't allocate copies of the entries */ 64 | map_put(&nb->map, e->key, e->value); 65 | } 66 | } 67 | 68 | struct membuf *new_named_buffer(struct named_buffer *nb, const char *name) 69 | { 70 | struct membuf *mp; 71 | 72 | mp = chunkpool_malloc(&nb->buf); 73 | /* name is already strdup:ped */ 74 | if(map_put(&nb->map, name, mp) != NULL) 75 | { 76 | /* found */ 77 | LOG(LOG_ERROR, ("buffer already exists.\n")); 78 | exit(-1); 79 | } 80 | membuf_init(mp); 81 | return mp; 82 | } 83 | 84 | struct membuf *get_named_buffer(struct named_buffer *nb, const char *name) 85 | { 86 | struct membuf *mp; 87 | 88 | mp = map_get(&nb->map, name); 89 | if(mp == NULL) 90 | { 91 | mp = new_named_buffer(nb, name); 92 | } 93 | 94 | return mp; 95 | } 96 | -------------------------------------------------------------------------------- /exomizer2/exodecrs/mainf.s: -------------------------------------------------------------------------------- 1 | ; ------------------------------------------------------------------- 2 | ; this file is intended to be assembled and linked with the cc65 toolchain. 3 | ; It has not been tested with any other assemblers or linkers. 4 | ; ------------------------------------------------------------------- 5 | ; ------------------------------------------------------------------- 6 | ; example usage of Krill's forward decruncher 7 | ; this program will just decrunch some data to memory and print 8 | ; the amount of time it took. 9 | ; ------------------------------------------------------------------- 10 | .import decrunch 11 | .export get_crunched_byte 12 | .import start_of_data 13 | 14 | .byte $01,$08,$0b,$08,<2003,>2003,$9e,'2','0','6','1',0,0,0 15 | ; ------------------------------------------------------------------- 16 | ; we begin here 17 | ; ------------------------------------------------------------------- 18 | sei 19 | jsr reset_cia1_tod 20 | inc $01 21 | jsr decrunch 22 | dec $01 23 | jsr print_cia1_tod 24 | cli 25 | rts 26 | ; ------------------------------------------------------------------- 27 | get_crunched_byte: 28 | dec $01 29 | sta $d020 30 | eor $0400 31 | sta $0400 32 | inc $01 33 | _byte_lo = * + 1 34 | _byte_hi = * + 2 35 | lda start_of_data ; needs to be set correctly before 36 | ; decrunch_file is called. 37 | inc _byte_lo 38 | bne _byte_skip_hi 39 | inc _byte_hi 40 | _byte_skip_hi: 41 | rts 42 | ; end_of_data needs to point to the address just after the address 43 | ; of the last byte of crunched data. 44 | ; ------------------------------------------------------------------- 45 | reset_cia1_tod: 46 | lda $dc0e 47 | ora #$80 ; set pal bit 48 | sta $dc0e 49 | 50 | lda $dc0f 51 | and #$7f ; TOD, not alarm mode 52 | sta $dc0f 53 | 54 | lda #00 55 | sta $dc0b 56 | sta $dc0a 57 | sta $dc09 58 | sta $dc08 59 | rts 60 | ; ------------------------------------------------------------------- 61 | print_cia1_tod: 62 | lda $dc08 + 3 63 | sta tabell + 3 64 | lda $dc08 + 2 65 | sta tabell + 2 66 | lda $dc08 + 1 67 | sta tabell + 1 68 | lda $dc08 69 | sta tabell 70 | 71 | ;; timmar 72 | lda tabell + 3 73 | jsr print_byte 74 | 75 | lda #':' 76 | jsr $ffd2 77 | 78 | ;; minuter 79 | lda tabell + 2 80 | jsr print_byte 81 | 82 | lda #':' 83 | jsr $ffd2 84 | 85 | ;; sekunder 86 | lda tabell + 1 87 | jsr print_byte 88 | 89 | lda #'.' 90 | jsr $ffd2 91 | 92 | ;; sekunder/10 93 | lda tabell 94 | asl 95 | asl 96 | asl 97 | asl 98 | jsr print_byte 99 | 100 | lda #$0d 101 | jsr $ffd2 102 | rts 103 | 104 | print_byte: 105 | pha 106 | lsr 107 | lsr 108 | lsr 109 | lsr 110 | tax 111 | lda hextab,x 112 | jsr $ffd2 113 | pla 114 | and #$0f 115 | tax 116 | lda hextab,x 117 | jsr $ffd2 118 | rts 119 | hextab: 120 | .asciiz "0123456789ABCDEF" 121 | tabell: 122 | .byte 0,0,0,0 123 | ; ------------------------------------------------------------------- 124 | -------------------------------------------------------------------------------- /exomizer2/exodecrs/main.s: -------------------------------------------------------------------------------- 1 | ; ------------------------------------------------------------------- 2 | ; this file is intended to be assembled and linked with the cc65 toolchain. 3 | ; It has not been tested with any other assemblers or linkers. 4 | ; ------------------------------------------------------------------- 5 | ; ------------------------------------------------------------------- 6 | ; example usage of the standard decruncher 7 | ; this program will just decrunch some data to memory and print 8 | ; the amount of time it took. 9 | ; ------------------------------------------------------------------- 10 | .import decrunch 11 | .export get_crunched_byte 12 | .import end_of_data 13 | 14 | .byte $01,$08,$0b,$08,<2003,>2003,$9e,'2','0','6','1',0,0,0 15 | ; ------------------------------------------------------------------- 16 | ; we begin here 17 | ; ------------------------------------------------------------------- 18 | sei 19 | jsr reset_cia1_tod 20 | inc $01 21 | jsr decrunch 22 | dec $01 23 | jsr print_cia1_tod 24 | cli 25 | rts 26 | ; ------------------------------------------------------------------- 27 | get_crunched_byte: 28 | lda _byte_lo 29 | bne _byte_skip_hi 30 | dec _byte_hi 31 | _byte_skip_hi: 32 | dec $01 33 | sta $d020 34 | eor $0400 35 | sta $0400 36 | inc $01 37 | 38 | dec _byte_lo 39 | _byte_lo = * + 1 40 | _byte_hi = * + 2 41 | lda end_of_data ; needs to be set correctly before 42 | rts ; decrunch_file is called. 43 | ; end_of_data needs to point to the address just after the address 44 | ; of the last byte of crunched data. 45 | ; ------------------------------------------------------------------- 46 | reset_cia1_tod: 47 | lda $dc0e 48 | ora #$80 ; set pal bit 49 | sta $dc0e 50 | 51 | lda $dc0f 52 | and #$7f ; TOD, not alarm mode 53 | sta $dc0f 54 | 55 | lda #00 56 | sta $dc0b 57 | sta $dc0a 58 | sta $dc09 59 | sta $dc08 60 | rts 61 | ; ------------------------------------------------------------------- 62 | print_cia1_tod: 63 | lda $dc08 + 3 64 | sta tabell + 3 65 | lda $dc08 + 2 66 | sta tabell + 2 67 | lda $dc08 + 1 68 | sta tabell + 1 69 | lda $dc08 70 | sta tabell 71 | 72 | ;; timmar 73 | lda tabell + 3 74 | jsr print_byte 75 | 76 | lda #':' 77 | jsr $ffd2 78 | 79 | ;; minuter 80 | lda tabell + 2 81 | jsr print_byte 82 | 83 | lda #':' 84 | jsr $ffd2 85 | 86 | ;; sekunder 87 | lda tabell + 1 88 | jsr print_byte 89 | 90 | lda #'.' 91 | jsr $ffd2 92 | 93 | ;; sekunder/10 94 | lda tabell 95 | asl 96 | asl 97 | asl 98 | asl 99 | jsr print_byte 100 | 101 | lda #$0d 102 | jsr $ffd2 103 | rts 104 | 105 | print_byte: 106 | pha 107 | lsr 108 | lsr 109 | lsr 110 | lsr 111 | tax 112 | lda hextab,x 113 | jsr $ffd2 114 | pla 115 | and #$0f 116 | tax 117 | lda hextab,x 118 | jsr $ffd2 119 | rts 120 | hextab: 121 | .asciiz "0123456789ABCDEF" 122 | tabell: 123 | .byte 0,0,0,0 124 | ; ------------------------------------------------------------------- 125 | -------------------------------------------------------------------------------- /exomizer/decruncher/main.s: -------------------------------------------------------------------------------- 1 | ; ------------------------------------------------------------------- 2 | ; this file is intended to be assembled and linked with the cc65 toolchain. 3 | ; It has not been tested with any other assemblers or linkers. 4 | ; ------------------------------------------------------------------- 5 | ; ------------------------------------------------------------------- 6 | ; example usage of the standard decruncher 7 | ; this program will just decrunch some data to memory and print 8 | ; the amount of time it took. 9 | ; ------------------------------------------------------------------- 10 | .import decrunch 11 | .export get_crunched_byte 12 | .import end_of_data 13 | 14 | .byte $01,$08,$0b,$08,<2003,>2003,$9e,'2','0','6','1',0,0,0 15 | ; ------------------------------------------------------------------- 16 | ; we begin here 17 | ; ------------------------------------------------------------------- 18 | sei 19 | jsr reset_cia1_tod 20 | inc $01 21 | jsr decrunch 22 | dec $01 23 | jsr print_cia1_tod 24 | cli 25 | rts 26 | ; ------------------------------------------------------------------- 27 | get_crunched_byte: 28 | lda _byte_lo 29 | bne _byte_skip_hi 30 | dec _byte_hi 31 | _byte_skip_hi: 32 | dec $01 33 | sta $d020 34 | eor $0400 35 | sta $0400 36 | inc $01 37 | 38 | dec _byte_lo 39 | _byte_lo = * + 1 40 | _byte_hi = * + 2 41 | lda end_of_data ; needs to be set correctly before 42 | rts ; decrunch_file is called. 43 | ; end_of_data needs to point to the address just after the address 44 | ; of the last byte of crunched data. 45 | ; ------------------------------------------------------------------- 46 | reset_cia1_tod: 47 | lda $dc0e 48 | ora #$80 ; set pal bit 49 | sta $dc0e 50 | 51 | lda $dc0f 52 | and #$7f ; TOD, not alarm mode 53 | sta $dc0f 54 | 55 | lda #00 56 | sta $dc0b 57 | sta $dc0a 58 | sta $dc09 59 | sta $dc08 60 | rts 61 | ; ------------------------------------------------------------------- 62 | print_cia1_tod: 63 | lda $dc08 + 3 64 | sta tabell + 3 65 | lda $dc08 + 2 66 | sta tabell + 2 67 | lda $dc08 + 1 68 | sta tabell + 1 69 | lda $dc08 70 | sta tabell 71 | 72 | ;; timmar 73 | lda tabell + 3 74 | jsr print_byte 75 | 76 | lda #':' 77 | jsr $ffd2 78 | 79 | ;; minuter 80 | lda tabell + 2 81 | jsr print_byte 82 | 83 | lda #':' 84 | jsr $ffd2 85 | 86 | ;; sekunder 87 | lda tabell + 1 88 | jsr print_byte 89 | 90 | lda #'.' 91 | jsr $ffd2 92 | 93 | ;; sekunder/10 94 | lda tabell 95 | asl 96 | asl 97 | asl 98 | asl 99 | jsr print_byte 100 | 101 | lda #$0d 102 | jsr $ffd2 103 | rts 104 | 105 | print_byte: 106 | pha 107 | lsr 108 | lsr 109 | lsr 110 | lsr 111 | tax 112 | lda hextab,x 113 | jsr $ffd2 114 | pla 115 | and #$0f 116 | tax 117 | lda hextab,x 118 | jsr $ffd2 119 | rts 120 | hextab: 121 | .asciiz "0123456789ABCDEF" 122 | tabell: 123 | .byte 0,0,0,0 124 | ; ------------------------------------------------------------------- 125 | -------------------------------------------------------------------------------- /exomizer/src/match.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_MATCH_H 2 | #define ALREADY_INCLUDED_MATCH_H 3 | /* 4 | * Copyright (c) 2002 - 2004 Magnus Lind. 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from 8 | * the use of this software. 9 | * 10 | * Permission is granted to anyone to use this software, alter it and re- 11 | * distribute it freely for any non-commercial, non-profit purpose subject to 12 | * the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not 15 | * claim that you wrote the original software. If you use this software in a 16 | * product, an acknowledgment in the product documentation would be 17 | * appreciated but is not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not 20 | * be misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any distribution. 23 | * 24 | * 4. The names of this software and/or it's copyright holders may not be 25 | * used to endorse or promote products derived from this software without 26 | * specific prior written permission. 27 | * 28 | */ 29 | 30 | #include "chunkpool.h" 31 | 32 | struct match { 33 | unsigned short int offset; 34 | unsigned short int len; 35 | struct match *next; 36 | }; 37 | 38 | typedef struct match match[1]; 39 | typedef struct match *matchp; 40 | typedef const struct match *const_matchp; 41 | 42 | struct pre_calc { 43 | struct match_node *single; 44 | const struct match *cache; 45 | }; 46 | 47 | typedef struct pre_calc pre_calc[1]; 48 | 49 | struct match_ctx { 50 | struct chunkpool m_pool[1]; 51 | pre_calc info[65536]; 52 | unsigned short int rle[65536]; 53 | unsigned short int rle_r[65536]; 54 | const unsigned char *buf; 55 | int len; 56 | int max_offset; 57 | }; 58 | 59 | typedef struct match_ctx match_ctx[1]; 60 | typedef struct match_ctx *match_ctxp; 61 | 62 | void match_ctx_init(match_ctx ctx, /* IN/OUT */ 63 | const unsigned char *buf, /* IN */ 64 | int buf_len, /* IN */ 65 | int max_offset); /* IN */ 66 | 67 | void match_ctx_free(match_ctx ctx); /* IN/OUT */ 68 | 69 | /* this needs to be called with the indexes in 70 | * reverse order */ 71 | const_matchp matches_get(match_ctx ctx, /* IN/OUT */ 72 | unsigned short int index); /* IN */ 73 | 74 | void match_delete(match_ctx ctx, /* IN/OUT */ 75 | matchp mp); /* IN */ 76 | 77 | struct matchp_cache_enum { 78 | match_ctxp ctx; 79 | const_matchp next; 80 | match tmp1; 81 | match tmp2; 82 | int pos; 83 | }; 84 | 85 | typedef struct matchp_cache_enum matchp_cache_enum[1]; 86 | typedef struct matchp_cache_enum *matchp_cache_enump; 87 | 88 | void matchp_cache_get_enum(match_ctx ctx, /* IN */ 89 | matchp_cache_enum mpce); /* IN/OUT */ 90 | 91 | typedef const_matchp matchp_enum_get_next_f(void *matchp_enum); /* IN/OUT */ 92 | 93 | const_matchp matchp_cache_enum_get_next(void *matchp_cache_enum); /* IN */ 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /exomizer2/src/match.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_MATCH 2 | #define ALREADY_INCLUDED_MATCH 3 | /* 4 | * Copyright (c) 2002 - 2005, 2013 Magnus Lind. 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from 8 | * the use of this software. 9 | * 10 | * Permission is granted to anyone to use this software, alter it and re- 11 | * distribute it freely for any non-commercial, non-profit purpose subject to 12 | * the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not 15 | * claim that you wrote the original software. If you use this software in a 16 | * product, an acknowledgment in the product documentation would be 17 | * appreciated but is not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not 20 | * be misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any distribution. 23 | * 24 | * 4. The names of this software and/or it's copyright holders may not be 25 | * used to endorse or promote products derived from this software without 26 | * specific prior written permission. 27 | * 28 | */ 29 | 30 | #include "chunkpool.h" 31 | #include "membuf.h" 32 | 33 | struct match { 34 | unsigned short int offset; 35 | unsigned short int len; 36 | struct match *next; 37 | }; 38 | 39 | typedef struct match match[1]; 40 | typedef struct match *matchp; 41 | typedef const struct match *const_matchp; 42 | 43 | struct pre_calc { 44 | struct match_node *single; 45 | const struct match *cache; 46 | }; 47 | 48 | struct match_ctx { 49 | struct chunkpool m_pool[1]; 50 | struct pre_calc (*info)[1]; 51 | unsigned short int *rle; 52 | unsigned short int *rle_r; 53 | const unsigned char *buf; 54 | int len; 55 | int max_offset; 56 | int max_len; 57 | }; 58 | 59 | typedef struct match_ctx match_ctx[1]; 60 | typedef struct match_ctx *match_ctxp; 61 | 62 | void match_ctx_init(match_ctx ctx, /* IN/OUT */ 63 | struct membuf *inbuf, /* IN */ 64 | int max_len, /* IN */ 65 | int max_offset, /* IN */ 66 | int use_imprecise_rle); /* IN */ 67 | 68 | void match_ctx_free(match_ctx ctx); /* IN/OUT */ 69 | 70 | /* this needs to be called with the indexes in 71 | * reverse order */ 72 | const_matchp matches_get(match_ctx ctx, /* IN/OUT */ 73 | int index); /* IN */ 74 | 75 | void match_delete(match_ctx ctx, /* IN/OUT */ 76 | matchp mp); /* IN */ 77 | 78 | struct matchp_cache_enum { 79 | match_ctxp ctx; 80 | const_matchp next; 81 | match tmp1; 82 | match tmp2; 83 | int pos; 84 | }; 85 | 86 | typedef struct matchp_cache_enum matchp_cache_enum[1]; 87 | typedef struct matchp_cache_enum *matchp_cache_enump; 88 | 89 | void matchp_cache_get_enum(match_ctx ctx, /* IN */ 90 | matchp_cache_enum mpce); /* IN/OUT */ 91 | 92 | typedef const_matchp matchp_enum_get_next_f(void *matchp_enum); /* IN/OUT */ 93 | 94 | const_matchp matchp_cache_enum_get_next(void *matchp_cache_enum); /* IN */ 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /exomizer2/src/vec.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_VEC 2 | #define ALREADY_INCLUDED_VEC 3 | 4 | /* 5 | * Copyright (c) 2003 - 2005 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | #include "callback.h" 32 | #include "membuf.h" 33 | #include 34 | #include 35 | 36 | #define STATIC_VEC_INIT(EL_SIZE) {(EL_SIZE), STATIC_MEMBUF_INIT, 1} 37 | 38 | struct vec { 39 | size_t elsize; 40 | struct membuf buf; 41 | int flags; 42 | }; 43 | 44 | struct vec_iterator { 45 | const struct vec *vec; 46 | int pos; 47 | }; 48 | 49 | void vec_init(struct vec *p, size_t elsize); 50 | void vec_clear(struct vec *p, cb_free * f); 51 | void vec_free(struct vec *p, cb_free * f); 52 | 53 | int vec_count(const struct vec *p); 54 | void *vec_get(const struct vec *p, int index); 55 | 56 | /** 57 | * Returns a pointer to the set area or null if the index is out of 58 | * bounds. 59 | **/ 60 | void *vec_set(struct vec *p, int index, const void *in); 61 | void *vec_insert(struct vec *p, int index, const void *in); 62 | void vec_remove(struct vec *p, int index); 63 | 64 | void *vec_push(struct vec *p, const void *in); 65 | 66 | /** 67 | * Gets the position where the key is stored in the vector. The vector 68 | * needs to be sorted for this function to work. Returns the position, 69 | * -1 on error or a negative number that can be converted to where 70 | * it should have been if it had been inserted. insert_pos = -(val + 2) 71 | **/ 72 | int vec_find(const struct vec *p, cb_cmp * f, const void *key); 73 | 74 | /** 75 | * Gets a pointer to the element that the key points to. 76 | * Returns a pointer that may be null if not found. 77 | **/ 78 | void *vec_find2(const struct vec *p, cb_cmp * f, const void *key); 79 | 80 | /** 81 | * Inserts the in element in its correct position in a sorted vector. 82 | * returns 1 if insertion is successful, 0 if element is already 83 | * present or -1 on error. If out is not NULL it will be 84 | * dereferenced and set to the inserted or present element. 85 | **/ 86 | int vec_insert_uniq(struct vec *p, cb_cmp * f, const void *in, void **out); 87 | void vec_sort(struct vec *p, cb_cmp * f); 88 | 89 | void vec_get_iterator(const struct vec *p, struct vec_iterator *i); 90 | void *vec_iterator_next(struct vec_iterator *i); 91 | 92 | int vec_equals(const struct vec *a, const struct vec *b, cb_cmp *equals); 93 | void vec_fprint(FILE *, const struct vec *a, cb_fprint *fprint); 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /exomizer2/src/search.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_SEARCH 2 | #define ALREADY_INCLUDED_SEARCH 3 | 4 | /* 5 | * Copyright (c) 2002 - 2005 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | #include "match.h" 32 | #include "output.h" 33 | 34 | struct _search_node { 35 | int index; 36 | match match; 37 | unsigned int total_offset; 38 | float total_score; 39 | struct _search_node *prev; 40 | }; 41 | 42 | typedef struct _search_node search_node[1]; 43 | typedef struct _search_node *search_nodep; 44 | typedef const struct _search_node *const_search_nodep; 45 | 46 | struct _encode_match_data { 47 | output_ctxp out; 48 | void *priv; 49 | }; 50 | 51 | typedef struct _encode_match_data encode_match_data[1]; 52 | typedef struct _encode_match_data *encode_match_datap; 53 | 54 | /* example of what may be used for priv data 55 | * field in the encode_match_data struct */ 56 | typedef 57 | float encode_int_f(int val, void *priv, output_ctxp out); /* IN */ 58 | 59 | struct _encode_match_priv { 60 | int lit_num; 61 | int seq_num; 62 | int rle_num; 63 | float lit_bits; 64 | float seq_bits; 65 | float rle_bits; 66 | 67 | encode_int_f *offset_f; 68 | encode_int_f *len_f; 69 | void *offset_f_priv; 70 | void *len_f_priv; 71 | 72 | output_ctxp out; 73 | }; 74 | 75 | typedef struct _encode_match_priv encode_match_priv[1]; 76 | typedef struct _encode_match_priv *encode_match_privp; 77 | /* end of example */ 78 | 79 | typedef 80 | float encode_match_f(const_matchp mp, encode_match_data emd); /* IN */ 81 | 82 | void search_node_dump(search_nodep snp); /* IN */ 83 | 84 | void search_node_free(search_nodep snp); /* IN/OUT */ 85 | 86 | search_nodep search_buffer(match_ctx ctx, /* IN */ 87 | encode_match_f * f, /* IN */ 88 | encode_match_data emd, 89 | int use_literal_sequences); /* IN */ 90 | 91 | struct _matchp_snp_enum { 92 | const_search_nodep startp; 93 | const_search_nodep currp; 94 | }; 95 | 96 | typedef struct _matchp_snp_enum matchp_snp_enum[1]; 97 | typedef struct _matchp_snp_enum *matchp_snp_enump; 98 | 99 | void matchp_snp_get_enum(const_search_nodep snp, /* IN */ 100 | matchp_snp_enum snpe); /* IN/OUT */ 101 | 102 | const_matchp matchp_snp_enum_get_next(void *matchp_snp_enum); 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /exomizer/src/vec.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003 Magnus Lind. 3 | * 4 | * This software is provided 'as-is', without any express or implied warranty. 5 | * In no event will the authors be held liable for any damages arising from 6 | * the use of this software. 7 | * 8 | * Permission is granted to anyone to use this software, alter it and re- 9 | * distribute it freely for any non-commercial, non-profit purpose subject to 10 | * the following restrictions: 11 | * 12 | * 1. The origin of this software must not be misrepresented; you must not 13 | * claim that you wrote the original software. If you use this software in a 14 | * product, an acknowledgment in the product documentation would be 15 | * appreciated but is not required. 16 | * 17 | * 2. Altered source versions must be plainly marked as such, and must not 18 | * be misrepresented as being the original software. 19 | * 20 | * 3. This notice may not be removed or altered from any distribution. 21 | * 22 | * 4. The names of this software and/or it's copyright holders may not be 23 | * used to endorse or promote products derived from this software without 24 | * specific prior written permission. 25 | * 26 | */ 27 | 28 | #include "vec.h" 29 | #include 30 | 31 | void vec_init(struct vec *p, size_t elsize) 32 | { 33 | p->elsize = elsize; 34 | membuf_init(&p->buf); 35 | } 36 | 37 | void vec_clear(struct vec *p, cb_free * f) 38 | { 39 | struct vec_iterator i; 40 | void *d; 41 | 42 | vec_get_iterator(p, &i); 43 | 44 | if (f != NULL) 45 | { 46 | while ((d = vec_iterator_next(&i)) != NULL) 47 | { 48 | f(d); 49 | } 50 | } 51 | membuf_clear(&p->buf); 52 | } 53 | 54 | void vec_free(struct vec *p, cb_free * f) 55 | { 56 | vec_clear(p, f); 57 | membuf_free(&p->buf); 58 | } 59 | 60 | int vec_count(struct vec *p) 61 | { 62 | int count; 63 | count = membuf_memlen(&p->buf) / p->elsize; 64 | return count; 65 | } 66 | 67 | void *vec_get(struct vec *p, int index) 68 | { 69 | char *buf; 70 | 71 | buf = (char *) membuf_get(&p->buf); 72 | buf += index * p->elsize; 73 | 74 | return (void *)buf; 75 | } 76 | 77 | void *vec_push(struct vec *p, const void *in) 78 | { 79 | void *out; 80 | out = membuf_append(&p->buf, in, p->elsize); 81 | 82 | return out; 83 | } 84 | 85 | void *vec_find(struct vec *p, cb_cmp * f, const void *in) 86 | { 87 | int count; 88 | void *out; 89 | 90 | count = vec_count(p); 91 | out = bsearch(in, membuf_get(&p->buf), count, p->elsize, f); 92 | 93 | return out; 94 | } 95 | 96 | int vec_insert_uniq(struct vec *p, cb_cmp * f, const void *in, void **outp) 97 | { 98 | int val = 0; 99 | void *out; 100 | 101 | if((out = vec_find(p, f, in)) == NULL) 102 | { 103 | vec_push(p, in); 104 | qsort(membuf_get(&p->buf), vec_count(p), p->elsize, f); 105 | 106 | out = vec_find(p, f, in); 107 | val = 1; 108 | } 109 | if(outp != NULL) 110 | { 111 | *outp = out; 112 | } 113 | 114 | return val; 115 | } 116 | 117 | void vec_get_iterator(struct vec *p, struct vec_iterator *i) 118 | { 119 | i->vec = p; 120 | i->pos = 0; 121 | } 122 | 123 | void *vec_iterator_next(struct vec_iterator *i) 124 | { 125 | void *out; 126 | int count = vec_count(i->vec); 127 | if (i->pos >= count) 128 | { 129 | return NULL; 130 | } 131 | out = vec_get(i->vec, i->pos); 132 | i->pos += 1; 133 | return out; 134 | } 135 | -------------------------------------------------------------------------------- /exomizer2/src/chunkpool.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003 - 2005, 2015 Magnus Lind. 3 | * 4 | * This software is provided 'as-is', without any express or implied warranty. 5 | * In no event will the authors be held liable for any damages arising from 6 | * the use of this software. 7 | * 8 | * Permission is granted to anyone to use this software, alter it and re- 9 | * distribute it freely for any non-commercial, non-profit purpose subject to 10 | * the following restrictions: 11 | * 12 | * 1. The origin of this software must not be misrepresented; you must not 13 | * claim that you wrote the original software. If you use this software in a 14 | * product, an acknowledgment in the product documentation would be 15 | * appreciated but is not required. 16 | * 17 | * 2. Altered source versions must be plainly marked as such, and must not 18 | * be misrepresented as being the original software. 19 | * 20 | * 3. This notice may not be removed or altered from any distribution. 21 | * 22 | * 4. The names of this software and/or it's copyright holders may not be 23 | * used to endorse or promote products derived from this software without 24 | * specific prior written permission. 25 | * 26 | */ 27 | 28 | #include "chunkpool.h" 29 | #include "log.h" 30 | #include 31 | #include 32 | 33 | void 34 | chunkpool_init(struct chunkpool *ctx, int item_size) 35 | { 36 | ctx->item_size = item_size; 37 | ctx->item_end = (0x1fffff / item_size) * item_size; 38 | ctx->item_pos = ctx->item_end; 39 | ctx->current_chunk = NULL; 40 | vec_init(&ctx->used_chunks, sizeof(void*)); 41 | } 42 | 43 | static void chunk_free(void *chunks, int item_pos, int item_size, cb_free *f) 44 | { 45 | if (chunks != NULL && f != NULL) 46 | { 47 | do 48 | { 49 | item_pos -= item_size; 50 | f((char*)chunks + item_pos); 51 | } 52 | while(item_pos > 0); 53 | } 54 | } 55 | 56 | void 57 | chunkpool_free2(struct chunkpool *ctx, cb_free *f) 58 | { 59 | void **chunkp; 60 | struct vec_iterator i; 61 | if (ctx->current_chunk != NULL) 62 | { 63 | chunk_free(ctx->current_chunk, ctx->item_pos, ctx->item_size, f); 64 | free(ctx->current_chunk); 65 | } 66 | vec_get_iterator(&ctx->used_chunks, &i); 67 | while ((chunkp = vec_iterator_next(&i)) != NULL) 68 | { 69 | chunk_free(*chunkp, ctx->item_end, ctx->item_size, f); 70 | free(*chunkp); 71 | } 72 | 73 | ctx->item_size = -1; 74 | ctx->item_end = -1; 75 | ctx->item_pos = -1; 76 | ctx->current_chunk = NULL; 77 | vec_free(&ctx->used_chunks, NULL); 78 | } 79 | 80 | void 81 | chunkpool_free(struct chunkpool *ctx) 82 | { 83 | chunkpool_free2(ctx, NULL); 84 | } 85 | 86 | void * 87 | chunkpool_malloc(struct chunkpool *ctx) 88 | { 89 | void *p; 90 | if(ctx->item_pos == ctx->item_end) 91 | { 92 | void *m; 93 | m = malloc(ctx->item_end); 94 | LOG(LOG_DEBUG, ("allocating new chunk %p\n", m)); 95 | if (m == NULL) 96 | { 97 | LOG(LOG_ERROR, ("out of memory error in file %s, line %d\n", 98 | __FILE__, __LINE__)); 99 | exit(-1); 100 | } 101 | vec_push(&ctx->used_chunks, &ctx->current_chunk); 102 | ctx->current_chunk = m; 103 | ctx->item_pos = 0; 104 | } 105 | p = (char*)ctx->current_chunk + ctx->item_pos; 106 | ctx->item_pos += ctx->item_size; 107 | return p; 108 | } 109 | 110 | void * 111 | chunkpool_calloc(struct chunkpool *ctx) 112 | { 113 | void *p = chunkpool_malloc(ctx); 114 | memset(p, 0, ctx->item_size); 115 | return p; 116 | } 117 | -------------------------------------------------------------------------------- /exomizer2/src/exo_helper.h: -------------------------------------------------------------------------------- 1 | #ifndef EXO_HELPER_ALREADY_INCLUDED 2 | #define EXO_HELPER_ALREADY_INCLUDED 3 | 4 | /* 5 | * Copyright (c) 2005, 2013, 2015 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | #include "log.h" 32 | #include "membuf.h" 33 | 34 | #define CRUNCH_OPTIONS_DEFAULT {NULL, 65535, 65535, 65535, 1, 0, 1} 35 | 36 | struct common_flags 37 | { 38 | struct crunch_options *options; 39 | const char *outfile; 40 | }; 41 | 42 | #define CRUNCH_FLAGS "cCe:Em:M:p:o:qv" 43 | #define BASE_FLAGS "o:qv" 44 | 45 | void print_crunch_flags(enum log_level level, const char *default_outfile); 46 | 47 | void print_base_flags(enum log_level level, const char *default_outfile); 48 | 49 | typedef void print_usage_f(const char *appl, enum log_level level, 50 | const char *default_outfile); 51 | 52 | void handle_crunch_flags(int flag_char, /* IN */ 53 | const char *flag_arg, /* IN */ 54 | print_usage_f *print_usage, /* IN */ 55 | const char *appl, /* IN */ 56 | struct common_flags *options); /* OUT */ 57 | 58 | void handle_base_flags(int flag_char, /* IN */ 59 | const char *flag_arg, /* IN */ 60 | print_usage_f *print_usage, /* IN */ 61 | const char *appl, /* IN */ 62 | const char **default_outfilep); /* OUT */ 63 | 64 | struct crunch_options 65 | { 66 | const char *exported_encoding; 67 | int max_passes; 68 | int max_len; 69 | int max_offset; 70 | int use_literal_sequences; 71 | int use_imprecise_rle; 72 | int output_header; 73 | }; 74 | 75 | struct crunch_info 76 | { 77 | int literal_sequences_used; 78 | int needed_safety_offset; 79 | }; 80 | 81 | void print_license(void); 82 | 83 | void crunch_backwards(struct membuf *inbuf, 84 | struct membuf *outbuf, 85 | struct crunch_options *options, /* IN */ 86 | struct crunch_info *info); /* OUT */ 87 | 88 | void crunch(struct membuf *inbuf, 89 | struct membuf *outbuf, 90 | struct crunch_options *options, /* IN */ 91 | struct crunch_info *info); /* OUT */ 92 | 93 | void decrunch(int level, 94 | struct membuf *inbuf, 95 | struct membuf *outbuf); 96 | 97 | void decrunch_backwards(int level, 98 | struct membuf *inbuf, 99 | struct membuf *outbuf); 100 | 101 | void reverse_buffer(char *start, int len); 102 | #endif 103 | -------------------------------------------------------------------------------- /exomizer/decruncher/main1.s: -------------------------------------------------------------------------------- 1 | ; ------------------------------------------------------------------- 2 | ; this file is intended to be assembled and linked with the cc65 toolchain. 3 | ; It has not been tested with any other assemblers or linkers. 4 | ; ------------------------------------------------------------------- 5 | ; ------------------------------------------------------------------- 6 | ; example usage do the stream decruncher 7 | ; this program will just decrunch some data to memory and print 8 | ; the amount of time it took. 9 | ; ------------------------------------------------------------------- 10 | .import init_decruncher 11 | .import get_decrunched_byte 12 | .export get_crunched_byte 13 | .import end_of_data 14 | 15 | .export buffer_start_hi: absolute 16 | .export buffer_len_hi: absolute 17 | 18 | .byte $01,$08,$0b,$08,<2003,>2003,$9e,'2','0','6','1',0,0,0 19 | ; ------------------------------------------------------------------- 20 | ; we begin here 21 | ; ------------------------------------------------------------------- 22 | sei 23 | jsr reset_cia1_tod 24 | inc $01 25 | jsr init_decruncher 26 | lda #0 27 | sta $0400 28 | _sample_next: 29 | jsr get_decrunched_byte 30 | bcs _sample_end 31 | ;; do whatever you wish with the value in the accumulator 32 | ldx store_lo 33 | bne skip_store_dec_hi 34 | dec store_hi 35 | skip_store_dec_hi: 36 | dec store_lo 37 | store_lo = * + 1 38 | store_hi = * + 2 39 | .byte $8d, 0, 0 ;sta $0000 40 | 41 | dec $01 42 | sta $d020 43 | eor $0400 44 | sta $0400 45 | inc $01 46 | 47 | jmp _sample_next 48 | _sample_end: 49 | dec $01 50 | 51 | jsr print_cia1_tod 52 | cli 53 | rts 54 | ; ------------------------------------------------------------------- 55 | ; for this get_crunched_byte routine to work the crunched data has to be 56 | ; crunced using the -m and possibly the -l flags. Any other 57 | ; flag will just mess things up. 58 | get_crunched_byte: 59 | lda _byte_lo 60 | bne _byte_skip_hi 61 | dec _byte_hi 62 | _byte_skip_hi: 63 | dec _byte_lo 64 | _byte_lo = * + 1 65 | _byte_hi = * + 2 66 | lda end_of_data ; needs to be set correctly before 67 | rts ; decrunch_file is called. 68 | ; end_of_data needs to point to the address just after the address 69 | ; of the last byte of crunched data. 70 | ; ------------------------------------------------------------------- 71 | reset_cia1_tod: 72 | lda $dc0e 73 | ora #$80 ; set pal bit 74 | sta $dc0e 75 | 76 | lda $dc0f 77 | and #$7f ; TOD, not alarm mode 78 | sta $dc0f 79 | 80 | lda #00 81 | sta $dc0b 82 | sta $dc0a 83 | sta $dc09 84 | sta $dc08 85 | rts 86 | ; ------------------------------------------------------------------- 87 | print_cia1_tod: 88 | lda $dc08 + 3 89 | sta tabell + 3 90 | lda $dc08 + 2 91 | sta tabell + 2 92 | lda $dc08 + 1 93 | sta tabell + 1 94 | lda $dc08 95 | sta tabell 96 | 97 | ;; timmar 98 | lda tabell + 3 99 | jsr print_byte 100 | 101 | lda #':' 102 | jsr $ffd2 103 | 104 | ;; minuter 105 | lda tabell + 2 106 | jsr print_byte 107 | 108 | lda #':' 109 | jsr $ffd2 110 | 111 | ;; sekunder 112 | lda tabell + 1 113 | jsr print_byte 114 | 115 | lda #'.' 116 | jsr $ffd2 117 | 118 | ;; sekunder/10 119 | lda tabell 120 | asl 121 | asl 122 | asl 123 | asl 124 | jsr print_byte 125 | 126 | lda #$0d 127 | jsr $ffd2 128 | rts 129 | 130 | print_byte: 131 | pha 132 | lsr 133 | lsr 134 | lsr 135 | lsr 136 | tax 137 | lda hextab,x 138 | jsr $ffd2 139 | pla 140 | and #$0f 141 | tax 142 | lda hextab,x 143 | jsr $ffd2 144 | rts 145 | hextab: 146 | .asciiz "0123456789ABCDEF" 147 | tabell: 148 | .byte 0,0,0,0 149 | ; ------------------------------------------------------------------- 150 | 151 | buffer_len_hi = 4 ; 1k 152 | unaligned_buffer: 153 | .res (buffer_len_hi * 256) + 255 154 | buffer_start_hi = (unaligned_buffer + 255) / 256 155 | 156 | -------------------------------------------------------------------------------- /exomizer2/exodecrs/main1.s: -------------------------------------------------------------------------------- 1 | ; ------------------------------------------------------------------- 2 | ; this file is intended to be assembled and linked with the cc65 toolchain. 3 | ; It has not been tested with any other assemblers or linkers. 4 | ; ------------------------------------------------------------------- 5 | ; ------------------------------------------------------------------- 6 | ; example usage do the stream decruncher 7 | ; this program will just decrunch some data to memory and print 8 | ; the amount of time it took. 9 | ; ------------------------------------------------------------------- 10 | .import init_decruncher 11 | .import get_decrunched_byte 12 | .export get_crunched_byte 13 | .import end_of_data 14 | 15 | .export buffer_start_hi: absolute 16 | .export buffer_len_hi: absolute 17 | 18 | .byte $01,$08,$0b,$08,<2003,>2003,$9e,'2','0','6','1',0,0,0 19 | ; ------------------------------------------------------------------- 20 | ; we begin here 21 | ; ------------------------------------------------------------------- 22 | sei 23 | jsr reset_cia1_tod 24 | inc $01 25 | jsr init_decruncher 26 | lda #0 27 | sta $0400 28 | _sample_next: 29 | jsr get_decrunched_byte 30 | bcs _sample_end 31 | ;; do whatever you wish with the value in the accumulator 32 | ldx store_lo 33 | bne skip_store_dec_hi 34 | dec store_hi 35 | skip_store_dec_hi: 36 | dec store_lo 37 | store_lo = * + 1 38 | store_hi = * + 2 39 | .byte $8d, 0, 0 ;sta $0000 40 | 41 | dec $01 42 | sta $d020 43 | eor $0400 44 | sta $0400 45 | inc $01 46 | 47 | jmp _sample_next 48 | _sample_end: 49 | dec $01 50 | 51 | jsr print_cia1_tod 52 | cli 53 | rts 54 | ; ------------------------------------------------------------------- 55 | ; for this get_crunched_byte routine to work the crunched data has to be 56 | ; crunced using the -m and possibly the -l flags. Any other 57 | ; flag will just mess things up. 58 | get_crunched_byte: 59 | lda _byte_lo 60 | bne _byte_skip_hi 61 | dec _byte_hi 62 | _byte_skip_hi: 63 | dec _byte_lo 64 | _byte_lo = * + 1 65 | _byte_hi = * + 2 66 | lda end_of_data ; needs to be set correctly before 67 | rts ; decrunch_file is called. 68 | ; end_of_data needs to point to the address just after the address 69 | ; of the last byte of crunched data. 70 | ; ------------------------------------------------------------------- 71 | reset_cia1_tod: 72 | lda $dc0e 73 | ora #$80 ; set pal bit 74 | sta $dc0e 75 | 76 | lda $dc0f 77 | and #$7f ; TOD, not alarm mode 78 | sta $dc0f 79 | 80 | lda #00 81 | sta $dc0b 82 | sta $dc0a 83 | sta $dc09 84 | sta $dc08 85 | rts 86 | ; ------------------------------------------------------------------- 87 | print_cia1_tod: 88 | lda $dc08 + 3 89 | sta tabell + 3 90 | lda $dc08 + 2 91 | sta tabell + 2 92 | lda $dc08 + 1 93 | sta tabell + 1 94 | lda $dc08 95 | sta tabell 96 | 97 | ;; timmar 98 | lda tabell + 3 99 | jsr print_byte 100 | 101 | lda #':' 102 | jsr $ffd2 103 | 104 | ;; minuter 105 | lda tabell + 2 106 | jsr print_byte 107 | 108 | lda #':' 109 | jsr $ffd2 110 | 111 | ;; sekunder 112 | lda tabell + 1 113 | jsr print_byte 114 | 115 | lda #'.' 116 | jsr $ffd2 117 | 118 | ;; sekunder/10 119 | lda tabell 120 | asl 121 | asl 122 | asl 123 | asl 124 | jsr print_byte 125 | 126 | lda #$0d 127 | jsr $ffd2 128 | rts 129 | 130 | print_byte: 131 | pha 132 | lsr 133 | lsr 134 | lsr 135 | lsr 136 | tax 137 | lda hextab,x 138 | jsr $ffd2 139 | pla 140 | and #$0f 141 | tax 142 | lda hextab,x 143 | jsr $ffd2 144 | rts 145 | hextab: 146 | .asciiz "0123456789ABCDEF" 147 | tabell: 148 | .byte 0,0,0,0 149 | ; ------------------------------------------------------------------- 150 | 151 | buffer_len_hi = 4 ; 1k 152 | unaligned_buffer: 153 | .res (buffer_len_hi * 256) + 255 154 | buffer_start_hi = (unaligned_buffer + 255) / 256 155 | 156 | -------------------------------------------------------------------------------- /exomizer2/rawdecrs/exodecr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005 Magnus Lind. 3 | * 4 | * This software is provided 'as-is', without any express or implied warranty. 5 | * In no event will the authors be held liable for any damages arising from 6 | * the use of this software. 7 | * 8 | * Permission is granted to anyone to use this software for any purpose, 9 | * including commercial applications, and to alter it and redistribute it 10 | * freely, subject to the following restrictions: 11 | * 12 | * 1. The origin of this software must not be misrepresented * you must not 13 | * claim that you wrote the original software. If you use this software in a 14 | * product, an acknowledgment in the product documentation would be 15 | * appreciated but is not required. 16 | * 17 | * 2. Altered source versions must be plainly marked as such, and must not 18 | * be misrepresented as being the original software. 19 | * 20 | * 3. This notice may not be removed or altered from any distribution. 21 | * 22 | * 4. The names of this software and/or it's copyright holders may not be 23 | * used to endorse or promote products derived from this software without 24 | * specific prior written permission. 25 | */ 26 | 27 | #include "exodecr.h" 28 | 29 | static unsigned short int base[52]; 30 | static char bits[52]; 31 | static unsigned short int bit_buffer; 32 | 33 | static unsigned short int 34 | read_bits(const char **inp, int bit_count) 35 | { 36 | unsigned short int bits = 0; 37 | while(bit_count-- > 0) 38 | { 39 | if(bit_buffer == 1) 40 | { 41 | bit_buffer = 0x100 | (*--(*inp) & 0xff); 42 | } 43 | bits <<= 1; 44 | bits |= bit_buffer & 0x1; 45 | bit_buffer >>= 1; 46 | } 47 | return bits; 48 | } 49 | 50 | static void 51 | init_table(const char **inp) 52 | { 53 | int i; 54 | unsigned short int b2; 55 | 56 | for(i = 0; i < 52; ++i) 57 | { 58 | unsigned short int b1; 59 | if((i & 15) == 0) 60 | { 61 | b2 = 1; 62 | } 63 | base[i] = b2; 64 | 65 | b1 = read_bits(inp, 4); 66 | bits[i] = b1; 67 | 68 | b2 += 1 << b1; 69 | } 70 | } 71 | 72 | char * 73 | exo_decrunch(const char *in, char *out) 74 | { 75 | unsigned short int index; 76 | unsigned short int length; 77 | unsigned short int offset; 78 | char c; 79 | char literal; 80 | 81 | bit_buffer = *--in; 82 | 83 | init_table(&in); 84 | for(;;) 85 | { 86 | literal = read_bits(&in, 1); 87 | if(literal == 1) 88 | { 89 | /* literal byte */ 90 | length = 1; 91 | goto copy; 92 | } 93 | index = 0; 94 | while(read_bits(&in, 1) == 0) 95 | { 96 | ++index; 97 | } 98 | if(index == 16) 99 | { 100 | break; 101 | } 102 | if(index == 17) 103 | { 104 | literal = 1; 105 | length = read_bits(&in, 16); 106 | goto copy; 107 | } 108 | length = base[index] + read_bits(&in, bits[index]); 109 | switch(length) 110 | { 111 | case 1: 112 | index = 48 + read_bits(&in, 2); 113 | break; 114 | case 2: 115 | index = 32 + read_bits(&in, 4); 116 | break; 117 | default: 118 | index = 16 + read_bits(&in, 4); 119 | break; 120 | } 121 | offset = base[index] + read_bits(&in, bits[index]); 122 | copy: 123 | do 124 | { 125 | --out; 126 | if(literal) 127 | { 128 | c = *--in; 129 | } 130 | else 131 | { 132 | c = out[offset]; 133 | } 134 | *out = c; 135 | } 136 | while(--length > 0); 137 | } 138 | return out; 139 | } 140 | -------------------------------------------------------------------------------- /exomizer/src/bprg_link_patch.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003 Magnus Lind. 3 | * 4 | * This software is provided 'as-is', without any express or implied warranty. 5 | * In no event will the authors be held liable for any damages arising from 6 | * the use of this software. 7 | * 8 | * Permission is granted to anyone to use this software, alter it and re- 9 | * distribute it freely for any non-commercial, non-profit purpose subject to 10 | * the following restrictions: 11 | * 12 | * 1. The origin of this software must not be misrepresented; you must not 13 | * claim that you wrote the original software. If you use this software in a 14 | * product, an acknowledgment in the product documentation would be 15 | * appreciated but is not required. 16 | * 17 | * 2. Altered source versions must be plainly marked as such, and must not 18 | * be misrepresented as being the original software. 19 | * 20 | * 3. This notice may not be removed or altered from any distribution. 21 | * 22 | * 4. The names of this software and/or it's copyright holders may not be 23 | * used to endorse or promote products derived from this software without 24 | * specific prior written permission. 25 | * 26 | */ 27 | 28 | #include 29 | #include "bprg.h" 30 | #include "log.h" 31 | 32 | static int 33 | linkpatch_cb_line_mutate(const unsigned char *in, /* IN */ 34 | unsigned char *mem, /* IN/OUT */ 35 | unsigned short *pos, /* IN/OUT */ 36 | void *priv) /* IN/OUT */ 37 | { 38 | unsigned short start; 39 | unsigned short i; 40 | 41 | start = *pos; 42 | i = 0; 43 | 44 | /* skip link */ 45 | i += 2; in += 2; 46 | /* copy number */ 47 | mem[start + i++] = *(in++); 48 | mem[start + i++] = *(in++); 49 | /* copy line including terminating '\0' */ 50 | while((mem[start + i++] = *(in++)) != '\0'); 51 | 52 | /* the purpose of this whole "if" structure is to improve the 53 | * crunching of the basic program by changing the basic line 54 | * link pointers to something that crunches better. This is 55 | * possible since the basic normally recreates the links when 56 | * loading the basic program anyhow. However if we decrunch 57 | * the basic program this will not happen. But there is still 58 | * a nice subroutine that does the job for us that we can call 59 | * from the basic start trampoline */ 60 | 61 | /* link patching begins here */ 62 | if(mem[start + 2] == '\0' && mem[start + 4] != '\0') 63 | { 64 | /* mask 1, length 3 offset 3*/ 65 | mem[start + 0] = mem[start + 3]; 66 | mem[start + 1] = mem[start + 4]; 67 | 68 | } else if(mem[start + 3] == '\0' && mem[start + 5] != '\0') 69 | { 70 | /* mask 2, length 3 offset 4*/ 71 | mem[start + 0] = mem[start + 4]; 72 | mem[start + 1] = mem[start + 5]; 73 | 74 | } else if(mem[start + 3] != '\0') 75 | { 76 | /* mask 3, length 2 offset 2*/ 77 | mem[start + 0] = mem[start + 2]; 78 | mem[start + 1] = mem[start + 3]; 79 | 80 | } else if(mem[start + 4] != '\0') 81 | { 82 | /* mask 4, length 2 offset 3*/ 83 | mem[start + 0] = mem[start + 3]; 84 | mem[start + 1] = mem[start + 4]; 85 | } else 86 | { 87 | /* if we ever get here I have made a big mistake in 88 | assuming that the test (mem[start + 4] != '\0') always is true 89 | since empty basic lines are forbidden */ 90 | LOG(LOG_ERROR, ("Error, can't patch link (should be impossible)")); 91 | exit(1); 92 | } 93 | /* link patching ends here */ 94 | 95 | *pos = start + i; 96 | /* success */ 97 | return 0; 98 | } 99 | 100 | void 101 | bprg_link_patch(struct bprg_ctx *ctx) 102 | { 103 | bprg_lines_mutate(ctx, linkpatch_cb_line_mutate, NULL); 104 | LOG(LOG_VERBOSE, ("program length %hu\n", ctx->len)); 105 | } 106 | 107 | -------------------------------------------------------------------------------- /exomizer2/src/bprg_link_patch.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003 Magnus Lind. 3 | * 4 | * This software is provided 'as-is', without any express or implied warranty. 5 | * In no event will the authors be held liable for any damages arising from 6 | * the use of this software. 7 | * 8 | * Permission is granted to anyone to use this software, alter it and re- 9 | * distribute it freely for any non-commercial, non-profit purpose subject to 10 | * the following restrictions: 11 | * 12 | * 1. The origin of this software must not be misrepresented; you must not 13 | * claim that you wrote the original software. If you use this software in a 14 | * product, an acknowledgment in the product documentation would be 15 | * appreciated but is not required. 16 | * 17 | * 2. Altered source versions must be plainly marked as such, and must not 18 | * be misrepresented as being the original software. 19 | * 20 | * 3. This notice may not be removed or altered from any distribution. 21 | * 22 | * 4. The names of this software and/or it's copyright holders may not be 23 | * used to endorse or promote products derived from this software without 24 | * specific prior written permission. 25 | * 26 | */ 27 | 28 | #include 29 | #include "bprg.h" 30 | #include "log.h" 31 | 32 | static int 33 | linkpatch_cb_line_mutate(const unsigned char *in, /* IN */ 34 | unsigned char *mem, /* IN/OUT */ 35 | unsigned short *pos, /* IN/OUT */ 36 | void *priv) /* IN/OUT */ 37 | { 38 | unsigned short start; 39 | unsigned short i; 40 | 41 | start = *pos; 42 | i = 0; 43 | 44 | /* skip link */ 45 | i += 2; in += 2; 46 | /* copy number */ 47 | mem[start + i++] = *(in++); 48 | mem[start + i++] = *(in++); 49 | /* copy line including terminating '\0' */ 50 | while((mem[start + i++] = *(in++)) != '\0'); 51 | 52 | /* the purpose of this whole "if" structure is to improve the 53 | * crunching of the basic program by changing the basic line 54 | * link pointers to something that crunches better. This is 55 | * possible since the basic normally recreates the links when 56 | * loading the basic program anyhow. However if we decrunch 57 | * the basic program this will not happen. But there is still 58 | * a nice subroutine that does the job for us that we can call 59 | * from the basic start trampoline */ 60 | 61 | /* link patching begins here */ 62 | if(mem[start + 2] == '\0' && mem[start + 4] != '\0') 63 | { 64 | /* mask 1, length 3 offset 3*/ 65 | mem[start + 0] = mem[start + 3]; 66 | mem[start + 1] = mem[start + 4]; 67 | 68 | } else if(mem[start + 3] == '\0' && mem[start + 5] != '\0') 69 | { 70 | /* mask 2, length 3 offset 4*/ 71 | mem[start + 0] = mem[start + 4]; 72 | mem[start + 1] = mem[start + 5]; 73 | 74 | } else if(mem[start + 3] != '\0') 75 | { 76 | /* mask 3, length 2 offset 2*/ 77 | mem[start + 0] = mem[start + 2]; 78 | mem[start + 1] = mem[start + 3]; 79 | 80 | } else if(mem[start + 4] != '\0') 81 | { 82 | /* mask 4, length 2 offset 3*/ 83 | mem[start + 0] = mem[start + 3]; 84 | mem[start + 1] = mem[start + 4]; 85 | } else 86 | { 87 | /* if we ever get here I have made a big mistake in 88 | assuming that the test (mem[start + 4] != '\0') always is true 89 | since empty basic lines are forbidden */ 90 | LOG(LOG_ERROR, ("Error, can't patch link (should be impossible)")); 91 | exit(1); 92 | } 93 | /* link patching ends here */ 94 | 95 | *pos = start + i; 96 | /* success */ 97 | return 0; 98 | } 99 | 100 | void 101 | bprg_link_patch(struct bprg_ctx *ctx) 102 | { 103 | bprg_lines_mutate(ctx, linkpatch_cb_line_mutate, NULL); 104 | LOG(LOG_VERBOSE, ("program length %hu\n", ctx->len)); 105 | } 106 | 107 | -------------------------------------------------------------------------------- /exomizer/src/search.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_SEARCH_H 2 | #define ALREADY_INCLUDED_SEARCH_H 3 | 4 | /* 5 | * Copyright (c) 2002, 2003 Magnus Lind. 6 | * 7 | * This software is provided 'as-is', without any express or implied warranty. 8 | * In no event will the authors be held liable for any damages arising from 9 | * the use of this software. 10 | * 11 | * Permission is granted to anyone to use this software, alter it and re- 12 | * distribute it freely for any non-commercial, non-profit purpose subject to 13 | * the following restrictions: 14 | * 15 | * 1. The origin of this software must not be misrepresented; you must not 16 | * claim that you wrote the original software. If you use this software in a 17 | * product, an acknowledgment in the product documentation would be 18 | * appreciated but is not required. 19 | * 20 | * 2. Altered source versions must be plainly marked as such, and must not 21 | * be misrepresented as being the original software. 22 | * 23 | * 3. This notice may not be removed or altered from any distribution. 24 | * 25 | * 4. The names of this software and/or it's copyright holders may not be 26 | * used to endorse or promote products derived from this software without 27 | * specific prior written permission. 28 | * 29 | */ 30 | 31 | #include "match.h" 32 | #include "output.h" 33 | 34 | struct _search_node { 35 | int index; 36 | match match; 37 | float match_score; 38 | float total_score; 39 | struct _search_node *prev; 40 | }; 41 | 42 | typedef struct _search_node search_node[1]; 43 | typedef struct _search_node *search_nodep; 44 | typedef const struct _search_node *const_search_nodep; 45 | 46 | struct _encode_match_data { 47 | output_ctxp out; 48 | void *priv; 49 | }; 50 | 51 | typedef struct _encode_match_data encode_match_data[1]; 52 | typedef struct _encode_match_data *encode_match_datap; 53 | 54 | /* example of what may be used for priv data 55 | * field in the encode_match_data struct */ 56 | typedef 57 | float encode_int_f(int val, void *priv, output_ctxp out); /* IN */ 58 | 59 | struct _encode_match_priv { 60 | int lit_num; 61 | int seq_num; 62 | int rle_num; 63 | float lit_bits; 64 | float seq_bits; 65 | float rle_bits; 66 | 67 | encode_int_f *offset_f; 68 | encode_int_f *len_f; 69 | void *offset_f_priv; 70 | void *len_f_priv; 71 | 72 | output_ctxp out; 73 | }; 74 | 75 | typedef struct _encode_match_priv encode_match_priv[1]; 76 | typedef struct _encode_match_priv *encode_match_privp; 77 | /* end of example */ 78 | 79 | typedef 80 | float encode_match_f(const_matchp mp, encode_match_data emd); /* IN */ 81 | 82 | void search_node_dump(search_nodep snp); /* IN */ 83 | 84 | void search_node_free(search_nodep snp); /* IN/OUT */ 85 | 86 | search_nodep search_buffer(match_ctx ctx, /* IN */ 87 | encode_match_f * f, /* IN */ 88 | encode_match_data emd); /* IN */ 89 | 90 | struct _matchp_snp_enum { 91 | const_search_nodep startp; 92 | const_search_nodep currp; 93 | }; 94 | 95 | typedef struct _matchp_snp_enum matchp_snp_enum[1]; 96 | typedef struct _matchp_snp_enum *matchp_snp_enump; 97 | 98 | void matchp_snp_get_enum(const_search_nodep snp, /* IN */ 99 | matchp_snp_enum snpe); /* IN/OUT */ 100 | 101 | const_matchp matchp_snp_enum_get_next(void *matchp_snp_enum); 102 | 103 | 104 | struct _matchp_snp_rle_enum { 105 | const_search_nodep startp; 106 | const_search_nodep currp; 107 | const_search_nodep lastp; 108 | match m; 109 | }; 110 | 111 | typedef struct _matchp_snp_rle_enum matchp_snp_rle_enum[1]; 112 | typedef struct _matchp_snp_rle_enum *matchp_snp_rle_enump; 113 | 114 | void matchp_snp_rle_get_enum(const_search_nodep snp, /* IN */ 115 | matchp_snp_rle_enum snpe); /* IN/OUT */ 116 | 117 | const_matchp matchp_snp_rle_enum_get_next(void *matchp_snp_enum); 118 | 119 | #endif 120 | -------------------------------------------------------------------------------- /exomizer/src/membuf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002, 2003 Magnus Lind. 3 | * 4 | * This software is provided 'as-is', without any express or implied warranty. 5 | * In no event will the authors be held liable for any damages arising from 6 | * the use of this software. 7 | * 8 | * Permission is granted to anyone to use this software, alter it and re- 9 | * distribute it freely for any non-commercial, non-profit purpose subject to 10 | * the following restrictions: 11 | * 12 | * 1. The origin of this software must not be misrepresented; you must not 13 | * claim that you wrote the original software. If you use this software in a 14 | * product, an acknowledgment in the product documentation would be 15 | * appreciated but is not required. 16 | * 17 | * 2. Altered source versions must be plainly marked as such, and must not 18 | * be misrepresented as being the original software. 19 | * 20 | * 3. This notice may not be removed or altered from any distribution. 21 | * 22 | * 4. The names of this software and/or it's copyright holders may not be 23 | * used to endorse or promote products derived from this software without 24 | * specific prior written permission. 25 | * 26 | */ 27 | 28 | #include "membuf.h" 29 | #include 30 | #include 31 | #include 32 | 33 | void membuf_init(struct membuf *sb) 34 | { 35 | sb->buf = NULL; 36 | sb->len = 0; 37 | sb->size = 0; 38 | } 39 | void membuf_clear(struct membuf *sb) 40 | { 41 | sb->len = 0; 42 | } 43 | void membuf_free(struct membuf *sb) 44 | { 45 | if (sb->buf != NULL) 46 | { 47 | free(sb->buf); 48 | sb->buf = NULL; 49 | } 50 | sb->len = 0; 51 | sb->size = 0; 52 | } 53 | 54 | void membuf_new(struct membuf **sbp) 55 | { 56 | struct membuf *sb; 57 | 58 | sb = malloc(sizeof(struct membuf)); 59 | if (sb == NULL) 60 | { 61 | fprintf(stderr, "error, can't allocate memory\n"); 62 | exit(1); 63 | } 64 | sb->buf = NULL; 65 | sb->len = 0; 66 | sb->size = 0; 67 | 68 | *sbp = sb; 69 | } 70 | 71 | void membuf_delete(struct membuf **sbp) 72 | { 73 | struct membuf *sb; 74 | 75 | sb = *sbp; 76 | membuf_free(sb); 77 | free(sb); 78 | sb = NULL; 79 | *sbp = sb; 80 | } 81 | 82 | int membuf_memlen(struct membuf *sb) 83 | { 84 | return sb->len; 85 | } 86 | 87 | void *membuf_memcpy(struct membuf *sb, const void *mem, int memlen) 88 | { 89 | membuf_atleast(sb, memlen); 90 | memcpy(sb->buf, mem, memlen); 91 | return sb->buf; 92 | } 93 | void *membuf_append(struct membuf *sb, const void *mem, int memlen) 94 | { 95 | int len; 96 | void *p; 97 | len = sb->len + memlen; 98 | membuf_atleast(sb, len); 99 | p = (char *) sb->buf + sb->len; 100 | memcpy(p, mem, memlen); 101 | sb->len = len; 102 | return p; 103 | } 104 | 105 | void membuf_atleast(struct membuf *sb, int len) 106 | { 107 | int size; 108 | 109 | size = sb->size; 110 | if (size == 0) 111 | size = 1; 112 | while (size < len) 113 | { 114 | size <<= 1; 115 | } 116 | if (size > sb->size) 117 | { 118 | sb->buf = realloc(sb->buf, size); 119 | if (sb->buf == NULL) 120 | { 121 | fprintf(stderr, "error, can't reallocate memory\n"); 122 | exit(1); 123 | } 124 | sb->size = size; 125 | } 126 | } 127 | 128 | void membuf_atmost(struct membuf *sb, int len) 129 | { 130 | int size; 131 | 132 | size = sb->size; 133 | while (size > len) 134 | { 135 | size >>= 1; 136 | } 137 | if (size < sb->size) 138 | { 139 | sb->buf = realloc(sb->buf, size); 140 | if (sb->buf == NULL) 141 | { 142 | fprintf(stderr, "error, can't reallocate memory\n"); 143 | exit(1); 144 | } 145 | sb->size = size; 146 | sb->len = size; 147 | } 148 | } 149 | 150 | int membuf_get_size(struct membuf *sb) 151 | { 152 | return sb->size; 153 | } 154 | void *membuf_get(struct membuf *sb) 155 | { 156 | return sb->buf; 157 | } 158 | -------------------------------------------------------------------------------- /exomizer2/rawdecrs/z80/deexo_simple_b.asm: -------------------------------------------------------------------------------- 1 | ;Exomizer 2 Z80 decoder 2 | ; by Metalbrain 3 | ; 4 | ; optimized by Antonio Villena and Urusergi (152 bytes) 5 | ; 6 | ; compression algorithm by Magnus Lind 7 | 8 | ;input: hl=compressed data start 9 | ; de=uncompressed destination start 10 | ; 11 | ;simple version: 12 | ; no literal sequences (compress with -c option) 13 | ; you MUST define exo_mapbasebits aligned to a 256 boundary 14 | ; 15 | ;ATTENTION! 16 | ;A huge speed boost (around 14%) can be gained at the cost of only 5 bytes. 17 | ;If you want this, replace all instances of "call exo_getbit" with "srl a" followed by 18 | ;"call z,exo_getbit", and remove the first two instructions in exo_getbit routine. 19 | 20 | deexo: ld iy, exo_mapbasebits+112 21 | ld a, (hl) 22 | dec hl 23 | ld b, 52 24 | push de 25 | cp a 26 | exo_initbits: ld c, 16 27 | jr nz, exo_get4bits 28 | ld ixl, c 29 | ld de, 1 ;DE=b2 30 | exo_get4bits: call exo_getbit ;get one bit 31 | rl c 32 | jr nc, exo_get4bits 33 | ld (iy-112), c ;bits[i]=b1 34 | push hl 35 | ld hl, 1 36 | defb 210 ;3 bytes nop (JP NC) 37 | exo_setbit: add hl, hl 38 | dec c 39 | jr nz, exo_setbit 40 | ld (iy-60), e 41 | ld (iy-8), d ;base[i]=b2 42 | add hl, de 43 | ex de, hl 44 | inc iyl 45 | pop hl 46 | dec ixl 47 | djnz exo_initbits 48 | pop de 49 | defb 218 ;3 bytes nop (JP C) --> jr exo_mainloop 50 | exo_literal: ldd 51 | exo_mainloop: call exo_getbit ;get one bit 52 | jr c, exo_literal ;literal? 53 | ld c, 111 54 | exo_getindex: call exo_getbit ;get one bit 55 | inc c 56 | jr nc,exo_getindex 57 | ret m 58 | push de 59 | ld iyl, c 60 | call exo_getpair 61 | push de 62 | rlc d 63 | jr nz, exo_dontgo 64 | dec e 65 | ld bc, 512+160 ;2 bits, 48 offset 66 | jr z, exo_goforit 67 | dec e ;2? 68 | exo_dontgo: ld bc, 1024+144 ;4 bits, 32 offset 69 | jr z, exo_goforit 70 | ld c, 128 ;16 offset 71 | exo_goforit: call exo_getbits ;get B bits in DE 72 | ld iyl, c 73 | add iy, de 74 | call exo_getpair 75 | pop bc 76 | ex (sp), hl 77 | ex de, hl 78 | add hl, de 79 | lddr 80 | pop hl 81 | jr exo_mainloop ;Next! 82 | 83 | exo_getpair: ld b, (iy-112) 84 | call exo_getbits 85 | ex de, hl 86 | ld c, (iy-60) 87 | ld b, (iy-8) 88 | add hl, bc ;Always clear C flag 89 | ex de, hl 90 | ret 91 | 92 | exo_getbits: ld de, 0 93 | exo_gbcont: dec b 94 | ret m 95 | call exo_getbit 96 | rl e 97 | rl d 98 | jr exo_gbcont 99 | 100 | exo_getbit: srl a 101 | ret nz 102 | ld a, (hl) 103 | dec hl 104 | rra 105 | ret 106 | 107 | exo_mapbasebits:defs 156 ;tables for bits, baseL, baseH -------------------------------------------------------------------------------- /exomizer/decruncher/main2.s: -------------------------------------------------------------------------------- 1 | ; ------------------------------------------------------------------- 2 | ; this file is intended to be assembled and linked with the cc65 toolchain. 3 | ; It has not been tested with any other assemblers or linkers. 4 | ; ------------------------------------------------------------------- 5 | ; ------------------------------------------------------------------- 6 | ; example usage do the stream decruncher 7 | ; this program will just decrunch some data to memory and print 8 | ; the amount of time it took. 9 | ; ------------------------------------------------------------------- 10 | .import init_decruncher 11 | .import get_decrunched_chunk 12 | .export get_crunched_byte 13 | .import end_of_data 14 | 15 | .export buffer_start_hi: absolute 16 | .export buffer_len_hi: absolute 17 | .export decrunched_chunk_size: absolute 18 | 19 | decrunched_chunk_size = 128 20 | 21 | .byte $01,$08,$0b,$08,<2003,>2003,$9e,'2','0','6','1',0,0,0 22 | ; ------------------------------------------------------------------- 23 | ; we begin here 24 | ; ------------------------------------------------------------------- 25 | sei 26 | jsr reset_cia1_tod 27 | inc $01 28 | jsr init_decruncher 29 | lda #0 30 | sta $0400 31 | _sample_next: 32 | jsr get_decrunched_chunk 33 | bcs _sample_end 34 | ;; do whatever you wish with the value in the accumulator 35 | 36 | .if 1 37 | lda store_lo 38 | sec 39 | sbc #<(decrunched_chunk_size) 40 | sta store_lo 41 | bcs skip_store_dec_hi 42 | dec store_hi 43 | skip_store_dec_hi: 44 | 45 | ldy #<(decrunched_chunk_size - 1) 46 | _next_byte_in_chunk: 47 | lda ($fe),y 48 | store_lo = * + 1 49 | store_hi = * + 2 50 | .byte $99, 0, 0 ;sta $0000 51 | dey 52 | bpl _next_byte_in_chunk 53 | 54 | .endif 55 | dec $01 56 | sta $d020 57 | eor $0400 58 | sta $0400 59 | inc $01 60 | 61 | jmp _sample_next 62 | _sample_end: 63 | dec $01 64 | 65 | jsr print_cia1_tod 66 | cli 67 | rts 68 | ; ------------------------------------------------------------------- 69 | ; for this get_crunched_byte routine to work the crunched data has to be 70 | ; crunced using the -m and possibly the -l flags. Any other 71 | ; flag will just mess things up. 72 | get_crunched_byte: 73 | lda _byte_lo 74 | bne _byte_skip_hi 75 | dec _byte_hi 76 | _byte_skip_hi: 77 | dec _byte_lo 78 | _byte_lo = * + 1 79 | _byte_hi = * + 2 80 | lda end_of_data ; needs to be set correctly before 81 | rts ; decrunch_file is called. 82 | ; end_of_data needs to point to the address just after the address 83 | ; of the last byte of crunched data. 84 | ; ------------------------------------------------------------------- 85 | reset_cia1_tod: 86 | lda $dc0e 87 | ora #$80 ; set pal bit 88 | sta $dc0e 89 | 90 | lda $dc0f 91 | and #$7f ; TOD, not alarm mode 92 | sta $dc0f 93 | 94 | lda #00 95 | sta $dc0b 96 | sta $dc0a 97 | sta $dc09 98 | sta $dc08 99 | rts 100 | ; ------------------------------------------------------------------- 101 | print_cia1_tod: 102 | lda $dc08 + 3 103 | sta tabell + 3 104 | lda $dc08 + 2 105 | sta tabell + 2 106 | lda $dc08 + 1 107 | sta tabell + 1 108 | lda $dc08 109 | sta tabell 110 | 111 | ;; timmar 112 | lda tabell + 3 113 | jsr print_byte 114 | 115 | lda #':' 116 | jsr $ffd2 117 | 118 | ;; minuter 119 | lda tabell + 2 120 | jsr print_byte 121 | 122 | lda #':' 123 | jsr $ffd2 124 | 125 | ;; sekunder 126 | lda tabell + 1 127 | jsr print_byte 128 | 129 | lda #'.' 130 | jsr $ffd2 131 | 132 | ;; sekunder/10 133 | lda tabell 134 | asl 135 | asl 136 | asl 137 | asl 138 | jsr print_byte 139 | 140 | lda #$0d 141 | jsr $ffd2 142 | rts 143 | 144 | print_byte: 145 | pha 146 | lsr 147 | lsr 148 | lsr 149 | lsr 150 | tax 151 | lda hextab,x 152 | jsr $ffd2 153 | pla 154 | and #$0f 155 | tax 156 | lda hextab,x 157 | jsr $ffd2 158 | rts 159 | hextab: 160 | .asciiz "0123456789ABCDEF" 161 | tabell: 162 | .byte 0,0,0,0 163 | ; ------------------------------------------------------------------- 164 | buffer_len_hi = 4; 1k 165 | unaligned_buffer: 166 | .res (buffer_len_hi * 256) + 255 167 | buffer_start_hi = (unaligned_buffer + 255) / 256 168 | 169 | -------------------------------------------------------------------------------- /exomizer2/exodecrs/main2.s: -------------------------------------------------------------------------------- 1 | ; ------------------------------------------------------------------- 2 | ; this file is intended to be assembled and linked with the cc65 toolchain. 3 | ; It has not been tested with any other assemblers or linkers. 4 | ; ------------------------------------------------------------------- 5 | ; ------------------------------------------------------------------- 6 | ; example usage do the stream decruncher 7 | ; this program will just decrunch some data to memory and print 8 | ; the amount of time it took. 9 | ; ------------------------------------------------------------------- 10 | .import init_decruncher 11 | .import get_decrunched_chunk 12 | .export get_crunched_byte 13 | .import end_of_data 14 | 15 | .export buffer_start_hi: absolute 16 | .export buffer_len_hi: absolute 17 | .export decrunched_chunk_size: absolute 18 | 19 | decrunched_chunk_size = 128 20 | 21 | .byte $01,$08,$0b,$08,<2003,>2003,$9e,'2','0','6','1',0,0,0 22 | ; ------------------------------------------------------------------- 23 | ; we begin here 24 | ; ------------------------------------------------------------------- 25 | sei 26 | jsr reset_cia1_tod 27 | inc $01 28 | jsr init_decruncher 29 | lda #0 30 | sta $0400 31 | _sample_next: 32 | jsr get_decrunched_chunk 33 | bcs _sample_end 34 | ;; do whatever you wish with the value in the accumulator 35 | 36 | .if 1 37 | lda store_lo 38 | sec 39 | sbc #<(decrunched_chunk_size) 40 | sta store_lo 41 | bcs skip_store_dec_hi 42 | dec store_hi 43 | skip_store_dec_hi: 44 | 45 | ldy #<(decrunched_chunk_size - 1) 46 | _next_byte_in_chunk: 47 | lda ($fe),y 48 | store_lo = * + 1 49 | store_hi = * + 2 50 | .byte $99, 0, 0 ;sta $0000 51 | dey 52 | bpl _next_byte_in_chunk 53 | 54 | .endif 55 | dec $01 56 | sta $d020 57 | eor $0400 58 | sta $0400 59 | inc $01 60 | 61 | jmp _sample_next 62 | _sample_end: 63 | dec $01 64 | 65 | jsr print_cia1_tod 66 | cli 67 | rts 68 | ; ------------------------------------------------------------------- 69 | ; for this get_crunched_byte routine to work the crunched data has to be 70 | ; crunced using the -m and possibly the -l flags. Any other 71 | ; flag will just mess things up. 72 | get_crunched_byte: 73 | lda _byte_lo 74 | bne _byte_skip_hi 75 | dec _byte_hi 76 | _byte_skip_hi: 77 | dec _byte_lo 78 | _byte_lo = * + 1 79 | _byte_hi = * + 2 80 | lda end_of_data ; needs to be set correctly before 81 | rts ; decrunch_file is called. 82 | ; end_of_data needs to point to the address just after the address 83 | ; of the last byte of crunched data. 84 | ; ------------------------------------------------------------------- 85 | reset_cia1_tod: 86 | lda $dc0e 87 | ora #$80 ; set pal bit 88 | sta $dc0e 89 | 90 | lda $dc0f 91 | and #$7f ; TOD, not alarm mode 92 | sta $dc0f 93 | 94 | lda #00 95 | sta $dc0b 96 | sta $dc0a 97 | sta $dc09 98 | sta $dc08 99 | rts 100 | ; ------------------------------------------------------------------- 101 | print_cia1_tod: 102 | lda $dc08 + 3 103 | sta tabell + 3 104 | lda $dc08 + 2 105 | sta tabell + 2 106 | lda $dc08 + 1 107 | sta tabell + 1 108 | lda $dc08 109 | sta tabell 110 | 111 | ;; timmar 112 | lda tabell + 3 113 | jsr print_byte 114 | 115 | lda #':' 116 | jsr $ffd2 117 | 118 | ;; minuter 119 | lda tabell + 2 120 | jsr print_byte 121 | 122 | lda #':' 123 | jsr $ffd2 124 | 125 | ;; sekunder 126 | lda tabell + 1 127 | jsr print_byte 128 | 129 | lda #'.' 130 | jsr $ffd2 131 | 132 | ;; sekunder/10 133 | lda tabell 134 | asl 135 | asl 136 | asl 137 | asl 138 | jsr print_byte 139 | 140 | lda #$0d 141 | jsr $ffd2 142 | rts 143 | 144 | print_byte: 145 | pha 146 | lsr 147 | lsr 148 | lsr 149 | lsr 150 | tax 151 | lda hextab,x 152 | jsr $ffd2 153 | pla 154 | and #$0f 155 | tax 156 | lda hextab,x 157 | jsr $ffd2 158 | rts 159 | hextab: 160 | .asciiz "0123456789ABCDEF" 161 | tabell: 162 | .byte 0,0,0,0 163 | ; ------------------------------------------------------------------- 164 | buffer_len_hi = 4; 1k 165 | unaligned_buffer: 166 | .res (buffer_len_hi * 256) + 255 167 | buffer_start_hi = (unaligned_buffer + 255) / 256 168 | 169 | -------------------------------------------------------------------------------- /exomizer2/rawdecrs/z80/deexo_simple.asm: -------------------------------------------------------------------------------- 1 | ;Exomizer 2 Z80 decoder 2 | ; by Metalbrain 3 | ; 4 | ; optimized by Antonio Villena and Urusergi (154 bytes) 5 | ; 6 | ; compression algorithm by Magnus Lind 7 | 8 | ;input: hl=compressed data start 9 | ; de=uncompressed destination start 10 | ; 11 | ;simple version: 12 | ; no literal sequences (compress with -c option) 13 | ; you MUST define exo_mapbasebits aligned to a 256 boundary 14 | ; 15 | ;ATTENTION! 16 | ;A huge speed boost (around 14%) can be gained at the cost of only 5 bytes. 17 | ;If you want this, replace all instances of "call exo_getbit" with "srl a" followed by 18 | ;"call z,exo_getbit", and remove the first two instructions in exo_getbit routine. 19 | 20 | deexo: ld iy, exo_mapbasebits+112 21 | ld a, (hl) 22 | inc hl 23 | ld b, 52 24 | push de 25 | cp a 26 | exo_initbits: ld c, 16 27 | jr nz, exo_get4bits 28 | ld ixl, c 29 | ld de, 1 ;DE=b2 30 | exo_get4bits: call exo_getbit ;get one bit 31 | rl c 32 | jr nc, exo_get4bits 33 | ld (iy-112), c ;bits[i]=b1 34 | push hl 35 | ld hl, 1 36 | defb 210 ;3 bytes nop (JP NC) 37 | exo_setbit: add hl, hl 38 | dec c 39 | jr nz, exo_setbit 40 | ld (iy-60), e 41 | ld (iy-8), d ;base[i]=b2 42 | add hl, de 43 | ex de, hl 44 | inc iyl 45 | pop hl 46 | dec ixl 47 | djnz exo_initbits 48 | pop de 49 | defb 218 ;3 bytes nop (JP C) --> jr exo_mainloop 50 | exo_literal: ldi 51 | exo_mainloop: call exo_getbit ;get one bit 52 | jr c, exo_literal ;literal? 53 | ld c, 111 54 | exo_getindex: call exo_getbit ;get one bit 55 | inc c 56 | jr nc,exo_getindex 57 | ret m 58 | push de 59 | ld iyl, c 60 | call exo_getpair 61 | push de 62 | rlc d 63 | jr nz, exo_dontgo 64 | dec e 65 | ld bc, 512+160 ;2 bits, 48 offset 66 | jr z, exo_goforit 67 | dec e ;2? 68 | exo_dontgo: ld bc, 1024+144 ;4 bits, 32 offset 69 | jr z, exo_goforit 70 | ld c, 128 ;16 offset 71 | exo_goforit: call exo_getbits ;get B bits in DE 72 | ld iyl, c 73 | add iy, de 74 | call exo_getpair 75 | pop bc 76 | ex (sp), hl 77 | push hl 78 | sbc hl, de 79 | pop de 80 | ldir 81 | pop hl 82 | jr exo_mainloop ;Next! 83 | 84 | exo_getpair: ld b, (iy-112) 85 | call exo_getbits 86 | ex de, hl 87 | ld c, (iy-60) 88 | ld b, (iy-8) 89 | add hl, bc ;Always clear C flag 90 | ex de, hl 91 | ret 92 | 93 | exo_getbits: ld de, 0 94 | exo_gbcont: dec b 95 | ret m 96 | call exo_getbit 97 | rl e 98 | rl d 99 | jr exo_gbcont 100 | 101 | exo_getbit: srl a 102 | ret nz 103 | ld a, (hl) 104 | inc hl 105 | rra 106 | ret 107 | 108 | exo_mapbasebits:defs 156 ;tables for bits, baseL, baseH -------------------------------------------------------------------------------- /exomizer2/src/expr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005 Magnus Lind. 3 | * 4 | * This software is provided 'as-is', without any express or implied warranty. 5 | * In no event will the authors be held liable for any damages arising from 6 | * the use of this software. 7 | * 8 | * Permission is granted to anyone to use this software, alter it and re- 9 | * distribute it freely for any non-commercial, non-profit purpose subject to 10 | * the following restrictions: 11 | * 12 | * 1. The origin of this software must not be misrepresented; you must not 13 | * claim that you wrote the original software. If you use this software in a 14 | * product, an acknowledgment in the product documentation would be 15 | * appreciated but is not required. 16 | * 17 | * 2. Altered source versions must be plainly marked as such, and must not 18 | * be misrepresented as being the original software. 19 | * 20 | * 3. This notice may not be removed or altered from any distribution. 21 | * 22 | * 4. The names of this software and/or it's copyright holders may not be 23 | * used to endorse or promote products derived from this software without 24 | * specific prior written permission. 25 | * 26 | */ 27 | 28 | #include "expr.h" 29 | #include "chunkpool.h" 30 | #include "log.h" 31 | 32 | #include 33 | 34 | static struct chunkpool s_expr_pool[1]; 35 | 36 | void expr_init() 37 | { 38 | chunkpool_init(s_expr_pool, sizeof(struct expr)); 39 | } 40 | 41 | void expr_free() 42 | { 43 | chunkpool_free(s_expr_pool); 44 | } 45 | 46 | void expr_dump(int level, struct expr *e) 47 | { 48 | switch(e->expr_op) 49 | { 50 | case SYMBOL: 51 | LOG(level, ("expr %p symref %s\n", (void*)e, e->type.symref)); 52 | break; 53 | case NUMBER: 54 | LOG(level, ("expr %p number %d\n", (void*)e, e->type.number)); 55 | break; 56 | case vNEG: 57 | LOG(level, ("expr %p unary op %d, referring to %p\n", 58 | (void*)e, e->expr_op, (void*)e->type.arg1)); 59 | case LNOT: 60 | LOG(level, ("expr %p unary op %d, referring to %p\n", 61 | (void*)e, e->expr_op, (void*)e->type.arg1)); 62 | break; 63 | default: 64 | LOG(level, ("expr %p binary op %d, arg1 %p, arg2 %p\n", 65 | (void*)e, e->expr_op, (void*)e->type.arg1, 66 | (void*)e->expr_arg2)); 67 | 68 | } 69 | } 70 | 71 | struct expr *new_expr_op1(i16 op, struct expr *arg) 72 | { 73 | struct expr *val; 74 | 75 | if(op != vNEG && op != LNOT) 76 | { 77 | /* error, invalid unary operator */ 78 | LOG(LOG_ERROR, ("%d not allowed as unary operator\n", op)); 79 | exit(1); 80 | } 81 | 82 | val = chunkpool_malloc(s_expr_pool); 83 | val->expr_op = op; 84 | val->type.arg1 = arg; 85 | 86 | expr_dump(LOG_DEBUG, val); 87 | 88 | return val; 89 | } 90 | 91 | struct expr *new_expr_op2(i16 op, struct expr *arg1, struct expr *arg2) 92 | { 93 | struct expr *val; 94 | 95 | if(op == vNEG || 96 | op == LNOT || 97 | op == NUMBER || 98 | op == SYMBOL) 99 | { 100 | /* error, invalid binary operator */ 101 | printf("op %d, vNEG %d, NUMBER %d, SYMBOL %d\n", op, vNEG, NUMBER, SYMBOL); 102 | LOG(LOG_ERROR, ("%d not allowed as binary operator\n", op)); 103 | exit(1); 104 | } 105 | 106 | val = chunkpool_malloc(s_expr_pool); 107 | val->expr_op = op; 108 | val->type.arg1 = arg1; 109 | val->expr_arg2 = arg2; 110 | 111 | expr_dump(LOG_DEBUG, val); 112 | 113 | return val; 114 | } 115 | 116 | struct expr *new_expr_symref(const char *symbol) 117 | { 118 | struct expr *val; 119 | 120 | val = chunkpool_malloc(s_expr_pool); 121 | val->expr_op = SYMBOL; 122 | val->type.symref = symbol; 123 | 124 | expr_dump(LOG_DEBUG, val); 125 | 126 | return val; 127 | } 128 | 129 | struct expr *new_expr_number(i32 number) 130 | { 131 | struct expr *val; 132 | 133 | LOG(LOG_DEBUG, ("creating new number %d\n", number)); 134 | 135 | val = chunkpool_malloc(s_expr_pool); 136 | val->expr_op = NUMBER; 137 | val->type.number = number; 138 | 139 | expr_dump(LOG_DEBUG, val); 140 | 141 | return val; 142 | } 143 | -------------------------------------------------------------------------------- /exomizer/src/getflag.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002, 2003 Magnus Lind. 3 | * 4 | * This software is provided 'as-is', without any express or implied warranty. 5 | * In no event will the authors be held liable for any damages arising from 6 | * the use of this software. 7 | * 8 | * Permission is granted to anyone to use this software, alter it and re- 9 | * distribute it freely for any non-commercial, non-profit purpose subject to 10 | * the following restrictions: 11 | * 12 | * 1. The origin of this software must not be misrepresented; you must not 13 | * claim that you wrote the original software. If you use this software in a 14 | * product, an acknowledgment in the product documentation would be 15 | * appreciated but is not required. 16 | * 17 | * 2. Altered source versions must be plainly marked as such, and must not 18 | * be misrepresented as being the original software. 19 | * 20 | * 3. This notice may not be removed or altered from any distribution. 21 | * 22 | * 4. The names of this software and/or it's copyright holders may not be 23 | * used to endorse or promote products derived from this software without 24 | * specific prior written permission. 25 | * 26 | */ 27 | 28 | #include 29 | #include 30 | 31 | int flagind = 1; 32 | int flagflag = '?'; 33 | const char *flagarg = NULL; 34 | 35 | static void reverse(char **buf, int pos1, int pos2) 36 | { 37 | char **buf1; 38 | char **buf2; 39 | char *tmp; 40 | 41 | buf1 = buf + pos1; 42 | buf2 = buf + pos2 - 1; 43 | 44 | while (buf1 < buf2) 45 | { 46 | tmp = *buf1; 47 | *buf1 = *buf2; 48 | *buf2 = tmp; 49 | 50 | ++buf1; 51 | --buf2; 52 | } 53 | } 54 | 55 | 56 | int getflag(int argc, char **argv, const char *flags) 57 | { 58 | int argstart, flagstart, c; 59 | const char *flagp; 60 | 61 | c = -1; 62 | flagarg = NULL; 63 | argstart = flagind; 64 | flagstart = argc; 65 | 66 | /* skip over non-flags */ 67 | while (flagind < argc && argv[flagind][0] != '-') 68 | { 69 | ++flagind; 70 | } 71 | if (flagind == argc) 72 | { 73 | /* no more args */ 74 | flagind = argstart; 75 | return c; 76 | } 77 | /* we have an arg to work with */ 78 | do 79 | { 80 | flagstart = flagind; 81 | if (argv[flagind][1] == '-' && argv[flagind][2] == '\0') 82 | { 83 | /* stop parsing at '--' flag */ 84 | break; 85 | } 86 | c = flagflag = argv[flagind][1]; 87 | if (c == ':' || c == '\0') 88 | { 89 | /* this is an illegal flag */ 90 | c = '?'; 91 | break; 92 | } 93 | /* flag with arg */ 94 | if (argv[flagind][2] != '\0') 95 | { 96 | /* flag-arg in same argv[] */ 97 | flagarg = argv[flagind] + 2; 98 | } 99 | flagp = strchr(flags, c); 100 | if (flagp == NULL) 101 | { 102 | /* this is an unknown flag */ 103 | c = '?'; 104 | break; 105 | } 106 | if (flagarg != NULL || flagp[1] != ':') 107 | { 108 | if (flagarg != NULL && flagp[1] != ':') 109 | { 110 | /* error, a simple flag with an argument */ 111 | c = '?'; 112 | } 113 | break; 114 | } 115 | 116 | /* flag-arg is in the next argv[] */ 117 | if (flagind + 1 == argc) 118 | { 119 | /* auahh, no flag-arg */ 120 | flagstart = argstart; 121 | c = '?'; 122 | break; 123 | } 124 | flagarg = argv[++flagind]; 125 | } while (0); 126 | /* skip to next arg */ 127 | ++flagind; 128 | 129 | if (flagstart < flagind && argstart < flagstart) 130 | { 131 | /* we have found some args 132 | * we have also skipped over some non-args 133 | * shuffle the non-flag arg to the end of argv */ 134 | reverse(argv, argstart, flagstart); 135 | reverse(argv, flagstart, flagind); 136 | reverse(argv, argstart, flagind); 137 | } 138 | flagind = argstart + flagind - flagstart; 139 | 140 | return c; 141 | } 142 | -------------------------------------------------------------------------------- /exomizer2/src/getflag.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002, 2003 Magnus Lind. 3 | * 4 | * This software is provided 'as-is', without any express or implied warranty. 5 | * In no event will the authors be held liable for any damages arising from 6 | * the use of this software. 7 | * 8 | * Permission is granted to anyone to use this software, alter it and re- 9 | * distribute it freely for any non-commercial, non-profit purpose subject to 10 | * the following restrictions: 11 | * 12 | * 1. The origin of this software must not be misrepresented; you must not 13 | * claim that you wrote the original software. If you use this software in a 14 | * product, an acknowledgment in the product documentation would be 15 | * appreciated but is not required. 16 | * 17 | * 2. Altered source versions must be plainly marked as such, and must not 18 | * be misrepresented as being the original software. 19 | * 20 | * 3. This notice may not be removed or altered from any distribution. 21 | * 22 | * 4. The names of this software and/or it's copyright holders may not be 23 | * used to endorse or promote products derived from this software without 24 | * specific prior written permission. 25 | * 26 | */ 27 | 28 | #include 29 | #include 30 | 31 | int flagind = 1; 32 | int flagflag = '?'; 33 | const char *flagarg = NULL; 34 | 35 | static void reverse(char **buf, int pos1, int pos2) 36 | { 37 | char **buf1; 38 | char **buf2; 39 | char *tmp; 40 | 41 | buf1 = buf + pos1; 42 | buf2 = buf + pos2 - 1; 43 | 44 | while (buf1 < buf2) 45 | { 46 | tmp = *buf1; 47 | *buf1 = *buf2; 48 | *buf2 = tmp; 49 | 50 | ++buf1; 51 | --buf2; 52 | } 53 | } 54 | 55 | 56 | int getflag(int argc, char **argv, const char *flags) 57 | { 58 | int argstart, flagstart, c; 59 | const char *flagp; 60 | 61 | c = -1; 62 | flagarg = NULL; 63 | argstart = flagind; 64 | flagstart = argc; 65 | 66 | /* skip over non-flags */ 67 | while (flagind < argc && argv[flagind][0] != '-') 68 | { 69 | ++flagind; 70 | } 71 | if (flagind == argc) 72 | { 73 | /* no more args */ 74 | flagind = argstart; 75 | return c; 76 | } 77 | /* we have an arg to work with */ 78 | do 79 | { 80 | flagstart = flagind; 81 | if (argv[flagind][1] == '-' && argv[flagind][2] == '\0') 82 | { 83 | /* stop parsing at '--' flag */ 84 | break; 85 | } 86 | c = flagflag = argv[flagind][1]; 87 | if (c == ':' || c == '\0') 88 | { 89 | /* this is an illegal flag */ 90 | c = '?'; 91 | break; 92 | } 93 | /* flag with arg */ 94 | if (argv[flagind][2] != '\0') 95 | { 96 | /* flag-arg in same argv[] */ 97 | flagarg = argv[flagind] + 2; 98 | } 99 | flagp = strchr(flags, c); 100 | if (flagp == NULL) 101 | { 102 | /* this is an unknown flag */ 103 | c = '?'; 104 | break; 105 | } 106 | if (flagarg != NULL || flagp[1] != ':') 107 | { 108 | if (flagarg != NULL && flagp[1] != ':') 109 | { 110 | /* error, a simple flag with an argument */ 111 | c = '?'; 112 | } 113 | break; 114 | } 115 | 116 | /* flag-arg is in the next argv[] */ 117 | if (flagind + 1 == argc) 118 | { 119 | /* auahh, no flag-arg */ 120 | flagstart = argstart; 121 | c = '?'; 122 | break; 123 | } 124 | flagarg = argv[++flagind]; 125 | } while (0); 126 | /* skip to next arg */ 127 | ++flagind; 128 | 129 | if (flagstart < flagind && argstart < flagstart) 130 | { 131 | /* we have found some args 132 | * we have also skipped over some non-args 133 | * shuffle the non-flag arg to the end of argv */ 134 | reverse(argv, argstart, flagstart); 135 | reverse(argv, flagstart, flagind); 136 | reverse(argv, argstart, flagind); 137 | } 138 | flagind = argstart + flagind - flagstart; 139 | 140 | return c; 141 | } 142 | -------------------------------------------------------------------------------- /exomizer2/rawdecrs/z80/deexo_b.asm: -------------------------------------------------------------------------------- 1 | ;Exomizer 2 Z80 decoder 2 | ; by Metalbrain 3 | ; 4 | ; optimized by Antonio Villena and Urusergi (167 bytes) 5 | ; 6 | ; compression algorithm by Magnus Lind 7 | 8 | ;input: hl=compressed data start 9 | ; de=uncompressed destination start 10 | ; 11 | ; you may change exo_mapbasebits to point to any free buffer 12 | ; 13 | ;ATTENTION! 14 | ;A huge speed boost (around 14%) can be gained at the cost of only 5 bytes. 15 | ;If you want this, replace all instances of "call exo_getbit" with "srl a" followed by 16 | ;"call z,exo_getbit", and remove the first two instructions in exo_getbit routine. 17 | 18 | deexo: ld iy, exo_mapbasebits+11 19 | ld a, (hl) 20 | dec hl 21 | ld b, 52 22 | push de 23 | cp a 24 | exo_initbits: ld c, 16 25 | jr nz, exo_get4bits 26 | ld ixl, c 27 | ld de, 1 ;DE=b2 28 | exo_get4bits: call exo_getbit ;get one bit 29 | rl c 30 | jr nc, exo_get4bits 31 | inc c 32 | push hl 33 | ld hl, 1 34 | ld (iy+41), c ;bits[i]=b1 (and opcode 41 == add hl,hl) 35 | exo_setbit: dec c 36 | jr nz, exo_setbit-1 ;jump to add hl,hl instruction 37 | ld (iy-11), e 38 | ld (iy+93), d ;base[i]=b2 39 | add hl, de 40 | ex de, hl 41 | inc iy 42 | pop hl 43 | dec ixl 44 | djnz exo_initbits 45 | pop de 46 | jr exo_mainloop 47 | exo_literalrun: ld e, c ;DE=1 48 | exo_getbits: dec b 49 | ret z 50 | exo_getbits1: call exo_getbit 51 | rl e 52 | rl d 53 | jr nc, exo_getbits 54 | ld b, d 55 | ld c, e 56 | pop de 57 | exo_literalcopy:lddr 58 | exo_mainloop: inc c 59 | call exo_getbit ;literal? 60 | jr c, exo_literalcopy 61 | ld c, 239 62 | exo_getindex: call exo_getbit 63 | inc c 64 | jr nc,exo_getindex 65 | ret z 66 | push de 67 | ld d, b 68 | jp p, exo_literalrun 69 | ld iy, exo_mapbasebits-229 70 | call exo_getpair 71 | push de 72 | rlc d 73 | jr nz, exo_dontgo 74 | dec e 75 | ld bc, 512+32 ;2 bits, 48 offset 76 | jr z, exo_goforit 77 | dec e ;2? 78 | exo_dontgo: ld bc, 1024+16 ;4 bits, 32 offset 79 | jr z, exo_goforit 80 | ld de, 0 81 | ld c, d ;16 offset 82 | exo_goforit: call exo_getbits1 83 | ld iy, exo_mapbasebits+27 84 | add iy, de 85 | call exo_getpair 86 | pop bc 87 | ex (sp), hl 88 | ex de, hl 89 | add hl,de 90 | lddr 91 | pop hl 92 | jr exo_mainloop ;Next! 93 | 94 | exo_getpair: add iy, bc 95 | ld e, d 96 | ld b, (iy+41) 97 | call exo_getbits 98 | ex de, hl 99 | ld c, (iy-11) 100 | ld b, (iy+93) 101 | add hl, bc ;Always clear C flag 102 | ex de, hl 103 | ret 104 | 105 | exo_getbit: srl a 106 | ret nz 107 | ld a, (hl) 108 | dec hl 109 | rra 110 | ret 111 | 112 | exo_mapbasebits:defs 156 ;tables for bits, baseL, baseH -------------------------------------------------------------------------------- /exomizer2/exodecrs/testrun.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002 - 2008 Magnus Lind. 3 | * 4 | * This software is provided 'as-is', without any express or implied warranty. 5 | * In no event will the authors be held liable for any damages arising from 6 | * the use of this software. 7 | * 8 | * Permission is granted to anyone to use this software, alter it and re- 9 | * distribute it freely for any non-commercial, non-profit purpose subject to 10 | * the following restrictions: 11 | * 12 | * 1. The origin of this software must not be misrepresented; you must not 13 | * claim that you wrote the original software. If you use this software in a 14 | * product, an acknowledgment in the product documentation would be 15 | * appreciated but is not required. 16 | * 17 | * 2. Altered source versions must be plainly marked as such, and must not 18 | * be misrepresented as being the original software. 19 | * 20 | * 3. This notice may not be removed or altered from any distribution. 21 | * 22 | * 4. The names of this software and/or it's copyright holders may not be 23 | * used to endorse or promote products derived from this software without 24 | * specific prior written permission. 25 | * 26 | */ 27 | 28 | #include "../src/log.h" 29 | #include "../src/exo_util.h" 30 | #include "../src/6502emu.h" 31 | 32 | #include 33 | 34 | static void mem_access_write(struct mem_access *this, u16 address, u8 value) 35 | { 36 | u8 *mem = this->ctx; 37 | mem[address] = value; 38 | } 39 | 40 | static u8 mem_access_read(struct mem_access *this, u16 address) 41 | { 42 | u8 *mem = this->ctx; 43 | return mem[address]; 44 | } 45 | 46 | int main(int argc, char *argv[]) 47 | { 48 | struct cpu_ctx r; 49 | struct load_info info[1]; 50 | static unsigned char mem[65536]; 51 | static unsigned char mem2[65536]; 52 | int p; 53 | int pending; 54 | int fail; 55 | const char *appl; 56 | 57 | /* init logging */ 58 | LOG_INIT_CONSOLE(LOG_BRIEF); 59 | 60 | appl = fixup_appl(argv[0]); 61 | 62 | info->basic_txt_start = 0x0801; 63 | load_located(argv[1], mem, info); 64 | 65 | mem[0x02a7] = 0x60; 66 | 67 | /* no start address from load*/ 68 | if(info->run == -1) 69 | { 70 | /* look for sys line */ 71 | info->run = find_sys(mem + info->basic_txt_start, 0x9e); 72 | } 73 | if(info->run == -1) 74 | { 75 | LOG(LOG_ERROR, ("Error, can't find entry point.\n")); 76 | exit(-1); 77 | } 78 | 79 | LOG(LOG_DEBUG, ("run %04x\n", info->run)); 80 | 81 | r.cycles = 0; 82 | r.mem.ctx = mem; 83 | r.mem.read = mem_access_read; 84 | r.mem.write = mem_access_write; 85 | r.pc = info->run; 86 | r.sp = '\xff'; 87 | r.flags = 0; 88 | 89 | /* setting up decrunch */ 90 | while(r.sp >= 0x10) 91 | { 92 | /* redirect chrout to a safe rts */ 93 | if(r.pc == 0xffd2) 94 | { 95 | r.pc = 0x02a7; 96 | } 97 | next_inst(&r); 98 | } 99 | 100 | load_located(argv[2], mem2, info); 101 | LOG(LOG_BRIEF, ("comparing $%04X - $%04X\n", info->start, info->end)); 102 | p = info->start; 103 | fail = 0; 104 | pending = -1; 105 | while(p < info->end) 106 | { 107 | if(mem[p] != mem2[p]) 108 | { 109 | if(pending < 0) 110 | { 111 | pending = p; 112 | fail = 1; 113 | } 114 | } 115 | else 116 | { 117 | if(pending >= 0) 118 | { 119 | LOG(LOG_ERROR, ("%s: interval mismatch $%04X - $%04X, " 120 | "starts with $%02X, expected $%02X.\n", 121 | appl, pending, p - 1, 122 | mem[pending], 123 | mem2[pending])); 124 | pending = -1; 125 | } 126 | } 127 | ++p; 128 | } 129 | if(pending >= 0) 130 | { 131 | LOG(LOG_ERROR, ("%s: interval mismatch $%04X - $%04X, " 132 | "starts with $%02X, expected $%02X.\n", 133 | appl, pending, p - 1, 134 | mem[pending], 135 | mem2[pending])); 136 | } 137 | 138 | return fail; 139 | } 140 | -------------------------------------------------------------------------------- /exomizer2/rawdecrs/z80/deexo.asm: -------------------------------------------------------------------------------- 1 | ;Exomizer 2 Z80 decoder 2 | ; by Metalbrain 3 | ; 4 | ; optimized by Antonio Villena and Urusergi (169 bytes) 5 | ; 6 | ; compression algorithm by Magnus Lind 7 | 8 | ;input: hl=compressed data start 9 | ; de=uncompressed destination start 10 | ; 11 | ; you may change exo_mapbasebits to point to any free buffer 12 | ; 13 | ;ATTENTION! 14 | ;A huge speed boost (around 14%) can be gained at the cost of only 5 bytes. 15 | ;If you want this, replace all instances of "call exo_getbit" with "srl a" followed by 16 | ;"call z,exo_getbit", and remove the first two instructions in exo_getbit routine. 17 | 18 | deexo: ld iy, exo_mapbasebits+11 19 | ld a, (hl) 20 | inc hl 21 | ld b, 52 22 | push de 23 | cp a 24 | exo_initbits: ld c, 16 25 | jr nz, exo_get4bits 26 | ld ixl, c 27 | ld de, 1 ;DE=b2 28 | exo_get4bits: call exo_getbit ;get one bit 29 | rl c 30 | jr nc, exo_get4bits 31 | inc c 32 | push hl 33 | ld hl, 1 34 | ld (iy+41), c ;bits[i]=b1 (and opcode 41 == add hl,hl) 35 | exo_setbit: dec c 36 | jr nz, exo_setbit-1 ;jump to add hl,hl instruction 37 | ld (iy-11), e 38 | ld (iy+93), d ;base[i]=b2 39 | add hl, de 40 | ex de, hl 41 | inc iy 42 | pop hl 43 | dec ixl 44 | djnz exo_initbits 45 | pop de 46 | jr exo_mainloop 47 | exo_literalrun: ld e, c ;DE=1 48 | exo_getbits: dec b 49 | ret z 50 | exo_getbits1: call exo_getbit 51 | rl e 52 | rl d 53 | jr nc, exo_getbits 54 | ld b, d 55 | ld c, e 56 | pop de 57 | exo_literalcopy:ldir 58 | exo_mainloop: inc c 59 | call exo_getbit ;literal? 60 | jr c, exo_literalcopy 61 | ld c, 239 62 | exo_getindex: call exo_getbit 63 | inc c 64 | jr nc,exo_getindex 65 | ret z 66 | push de 67 | ld d, b 68 | jp p, exo_literalrun 69 | ld iy, exo_mapbasebits-229 70 | call exo_getpair 71 | push de 72 | rlc d 73 | jr nz, exo_dontgo 74 | dec e 75 | ld bc, 512+32 ;2 bits, 48 offset 76 | jr z, exo_goforit 77 | dec e ;2? 78 | exo_dontgo: ld bc, 1024+16 ;4 bits, 32 offset 79 | jr z, exo_goforit 80 | ld de, 0 81 | ld c, d ;16 offset 82 | exo_goforit: call exo_getbits1 83 | ld iy, exo_mapbasebits+27 84 | add iy, de 85 | call exo_getpair 86 | pop bc 87 | ex (sp), hl 88 | push hl 89 | sbc hl, de 90 | pop de 91 | ldir 92 | pop hl 93 | jr exo_mainloop ;Next! 94 | 95 | exo_getpair: add iy, bc 96 | ld e, d 97 | ld b, (iy+41) 98 | call exo_getbits 99 | ex de, hl 100 | ld c, (iy-11) 101 | ld b, (iy+93) 102 | add hl, bc ;Always clear C flag 103 | ex de, hl 104 | ret 105 | 106 | exo_getbit: srl a 107 | ret nz 108 | ld a, (hl) 109 | inc hl 110 | rra 111 | ret 112 | 113 | exo_mapbasebits:defs 156 ;tables for bits, baseL, baseH -------------------------------------------------------------------------------- /exomizer/src/log.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_LOG_H 2 | #define ALREADY_INCLUDED_LOG_H 3 | /* 4 | * Copyright (c) 2002, 2003 Magnus Lind. 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from 8 | * the use of this software. 9 | * 10 | * Permission is granted to anyone to use this software, alter it and re- 11 | * distribute it freely for any non-commercial, non-profit purpose subject to 12 | * the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not 15 | * claim that you wrote the original software. If you use this software in a 16 | * product, an acknowledgment in the product documentation would be 17 | * appreciated but is not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not 20 | * be misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any distribution. 23 | * 24 | * 4. The names of this software and/or it's copyright holders may not be 25 | * used to endorse or promote products derived from this software without 26 | * specific prior written permission. 27 | * 28 | */ 29 | 30 | #include 31 | #include 32 | 33 | enum log_level { 34 | LOG_MIN = -99, 35 | LOG_FATAL = -40, 36 | LOG_ERROR = -30, 37 | LOG_WARNING = -20, 38 | LOG_BRIEF = -10, 39 | LOG_NORMAL = 0, 40 | LOG_VERBOSE = 10, 41 | LOG_TRACE = 20, 42 | LOG_DEBUG = 30, 43 | LOG_DUMP = 40, 44 | LOG_MAX = 99 45 | }; 46 | 47 | typedef 48 | void log_formatter_f(FILE * out, /* IN */ 49 | enum log_level level, /* IN */ 50 | const char *context, /* IN */ 51 | const char *); /* IN */ 52 | 53 | /* 54 | * this log output function adds nothing 55 | */ 56 | void raw_log_formatter(FILE * out, /* IN */ 57 | enum log_level level, /* IN */ 58 | const char *context, /* IN */ 59 | const char *log); /* IN */ 60 | 61 | 62 | struct log_output; 63 | 64 | struct log_ctx; 65 | 66 | struct log_ctx *log_new(void); 67 | 68 | /* log_delete closes all added output streams 69 | * and files except for stdout and stderr 70 | */ 71 | void log_delete(struct log_ctx *ctx); 72 | 73 | void log_set_level(struct log_ctx *ctx, /* IN/OUT */ 74 | enum log_level level); /* IN */ 75 | 76 | void log_add_output_stream(struct log_ctx *ctx, /* IN/OUT */ 77 | enum log_level min, /* IN */ 78 | enum log_level max, /* IN */ 79 | log_formatter_f * default_f, /* IN */ 80 | FILE * out_stream); /* IN */ 81 | 82 | void log_vlog(struct log_ctx *ctx, /* IN */ 83 | enum log_level level, /* IN */ 84 | const char *context, /* IN */ 85 | log_formatter_f * f, /* IN */ 86 | const char *printf_str, /* IN */ 87 | va_list argp); 88 | 89 | 90 | void log_log_default(const char *printf_str, /* IN */ 91 | ...); 92 | 93 | /* some helper macros */ 94 | 95 | extern struct log_ctx *G_log_ctx; 96 | extern enum log_level G_log_level; 97 | extern enum log_level G_log_log_level; 98 | 99 | #define LOG_SET_LEVEL(L) \ 100 | do { \ 101 | log_set_level(G_log_ctx, (L)); \ 102 | G_log_level = (L); \ 103 | } while(0) 104 | 105 | #define LOG_INIT(L) \ 106 | do { \ 107 | G_log_ctx = log_new(); \ 108 | log_set_level(G_log_ctx, (L)); \ 109 | G_log_level = (L); \ 110 | } while(0) 111 | 112 | #define LOG_INIT_CONSOLE(X) \ 113 | do { \ 114 | G_log_ctx = log_new(); \ 115 | log_set_level(G_log_ctx, (X)); \ 116 | G_log_level = (X); \ 117 | log_add_output_stream(G_log_ctx, LOG_WARNING, LOG_MAX, NULL, stdout); \ 118 | log_add_output_stream(G_log_ctx, LOG_MIN, LOG_WARNING - 1, NULL, stderr); \ 119 | } while(0) 120 | 121 | #define LOG_FREE log_delete(G_log_ctx) 122 | 123 | #define LOG(L, M) \ 124 | do { \ 125 | if(G_log_level >= (L)) { \ 126 | G_log_log_level = (L); \ 127 | log_log_default M; \ 128 | } \ 129 | } while(0) 130 | 131 | #endif 132 | -------------------------------------------------------------------------------- /exomizer2/src/asm.tab.h: -------------------------------------------------------------------------------- 1 | /* A Bison parser, made by GNU Bison 3.0.2. */ 2 | 3 | /* Bison interface for Yacc-like parsers in C 4 | 5 | Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . */ 19 | 20 | /* As a special exception, you may create a larger work that contains 21 | part or all of the Bison parser skeleton and distribute that work 22 | under terms of your choice, so long as that work isn't itself a 23 | parser generator using the skeleton or a modified version thereof 24 | as a parser skeleton. Alternatively, if you modify or redistribute 25 | the parser skeleton itself, you may (at your option) remove this 26 | special exception, which will cause the skeleton and the resulting 27 | Bison output files to be licensed under the GNU General Public 28 | License without this special exception. 29 | 30 | This special exception was added by the Free Software Foundation in 31 | version 2.2 of Bison. */ 32 | 33 | #ifndef YY_YY_ASM_TAB_H_INCLUDED 34 | # define YY_YY_ASM_TAB_H_INCLUDED 35 | /* Debug traces. */ 36 | #ifndef YYDEBUG 37 | # define YYDEBUG 1 38 | #endif 39 | #if YYDEBUG 40 | extern int yydebug; 41 | #endif 42 | 43 | /* Token type. */ 44 | #ifndef YYTOKENTYPE 45 | # define YYTOKENTYPE 46 | enum yytokentype 47 | { 48 | INCLUDE = 258, 49 | IF = 259, 50 | DEFINED = 260, 51 | MACRO = 261, 52 | MACRO_STRING = 262, 53 | ORG = 263, 54 | ERROR = 264, 55 | ECHO1 = 265, 56 | INCBIN = 266, 57 | INCLEN = 267, 58 | INCWORD = 268, 59 | RES = 269, 60 | WORD = 270, 61 | BYTE = 271, 62 | LDA = 272, 63 | LDX = 273, 64 | LDY = 274, 65 | STA = 275, 66 | STX = 276, 67 | STY = 277, 68 | AND = 278, 69 | ORA = 279, 70 | EOR = 280, 71 | ADC = 281, 72 | SBC = 282, 73 | CMP = 283, 74 | CPX = 284, 75 | CPY = 285, 76 | TSX = 286, 77 | TXS = 287, 78 | PHA = 288, 79 | PLA = 289, 80 | PHP = 290, 81 | PLP = 291, 82 | SEI = 292, 83 | CLI = 293, 84 | NOP = 294, 85 | TYA = 295, 86 | TAY = 296, 87 | TXA = 297, 88 | TAX = 298, 89 | CLC = 299, 90 | SEC = 300, 91 | RTS = 301, 92 | JSR = 302, 93 | JMP = 303, 94 | BEQ = 304, 95 | BNE = 305, 96 | BCC = 306, 97 | BCS = 307, 98 | BPL = 308, 99 | BMI = 309, 100 | BVC = 310, 101 | BVS = 311, 102 | INX = 312, 103 | DEX = 313, 104 | INY = 314, 105 | DEY = 315, 106 | INC = 316, 107 | DEC = 317, 108 | LSR = 318, 109 | ASL = 319, 110 | ROR = 320, 111 | ROL = 321, 112 | BIT = 322, 113 | SYMBOL = 323, 114 | STRING = 324, 115 | LAND = 325, 116 | LOR = 326, 117 | LNOT = 327, 118 | LPAREN = 328, 119 | RPAREN = 329, 120 | COMMA = 330, 121 | COLON = 331, 122 | X = 332, 123 | Y = 333, 124 | HASH = 334, 125 | PLUS = 335, 126 | MINUS = 336, 127 | MULT = 337, 128 | DIV = 338, 129 | MOD = 339, 130 | LT = 340, 131 | GT = 341, 132 | EQ = 342, 133 | NEQ = 343, 134 | ASSIGN = 344, 135 | GUESS = 345, 136 | NUMBER = 346, 137 | vNEG = 347 138 | }; 139 | #endif 140 | 141 | /* Value type. */ 142 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED 143 | typedef union YYSTYPE YYSTYPE; 144 | union YYSTYPE 145 | { 146 | #line 145 "asm.y" /* yacc.c:1909 */ 147 | 148 | i32 num; 149 | char *str; 150 | struct atom *atom; 151 | struct expr *expr; 152 | 153 | #line 154 "asm.tab.h" /* yacc.c:1909 */ 154 | }; 155 | # define YYSTYPE_IS_TRIVIAL 1 156 | # define YYSTYPE_IS_DECLARED 1 157 | #endif 158 | 159 | 160 | extern YYSTYPE yylval; 161 | 162 | int yyparse (void); 163 | 164 | #endif /* !YY_YY_ASM_TAB_H_INCLUDED */ 165 | -------------------------------------------------------------------------------- /exomizer2/src/log.h: -------------------------------------------------------------------------------- 1 | #ifndef ALREADY_INCLUDED_LOG 2 | #define ALREADY_INCLUDED_LOG 3 | /* 4 | * Copyright (c) 2002, 2003 Magnus Lind. 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from 8 | * the use of this software. 9 | * 10 | * Permission is granted to anyone to use this software, alter it and re- 11 | * distribute it freely for any non-commercial, non-profit purpose subject to 12 | * the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not 15 | * claim that you wrote the original software. If you use this software in a 16 | * product, an acknowledgment in the product documentation would be 17 | * appreciated but is not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not 20 | * be misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any distribution. 23 | * 24 | * 4. The names of this software and/or it's copyright holders may not be 25 | * used to endorse or promote products derived from this software without 26 | * specific prior written permission. 27 | * 28 | */ 29 | 30 | #include 31 | #include 32 | 33 | #ifndef __GNUC__ 34 | #define __attribute__(x) /*NOTHING*/ 35 | #endif 36 | 37 | enum log_level { 38 | LOG_MIN = -99, 39 | LOG_FATAL = -40, 40 | LOG_ERROR = -30, 41 | LOG_WARNING = -20, 42 | LOG_BRIEF = -10, 43 | LOG_NORMAL = 0, 44 | LOG_VERBOSE = 10, 45 | LOG_TRACE = 20, 46 | LOG_DEBUG = 30, 47 | LOG_DUMP = 40, 48 | LOG_MAX = 99 49 | }; 50 | 51 | typedef 52 | void log_formatter_f(FILE * out, /* IN */ 53 | enum log_level level, /* IN */ 54 | const char *context, /* IN */ 55 | const char *); /* IN */ 56 | 57 | /* 58 | * this log output function adds nothing 59 | */ 60 | void raw_log_formatter(FILE * out, /* IN */ 61 | enum log_level level, /* IN */ 62 | const char *context, /* IN */ 63 | const char *log); /* IN */ 64 | 65 | 66 | struct log_output; 67 | 68 | struct log_ctx; 69 | 70 | struct log_ctx *log_new(void); 71 | 72 | /* log_delete closes all added output streams 73 | * and files except for stdout and stderr 74 | */ 75 | void log_delete(struct log_ctx *ctx); 76 | 77 | void log_set_level(struct log_ctx *ctx, /* IN/OUT */ 78 | enum log_level level); /* IN */ 79 | 80 | void log_add_output_stream(struct log_ctx *ctx, /* IN/OUT */ 81 | enum log_level min, /* IN */ 82 | enum log_level max, /* IN */ 83 | log_formatter_f * default_f, /* IN */ 84 | FILE * out_stream); /* IN */ 85 | 86 | void log_vlog(struct log_ctx *ctx, /* IN */ 87 | enum log_level level, /* IN */ 88 | const char *context, /* IN */ 89 | log_formatter_f * f, /* IN */ 90 | const char *printf_str, /* IN */ 91 | va_list argp); 92 | 93 | 94 | void log_log_default(const char *printf_str, /* IN */ 95 | ...) 96 | __attribute__((format(printf,1,2))); 97 | 98 | /* some helper macros */ 99 | 100 | extern struct log_ctx *G_log_ctx; 101 | extern enum log_level G_log_level; 102 | extern enum log_level G_log_log_level; 103 | 104 | #define LOG_SET_LEVEL(L) \ 105 | do { \ 106 | log_set_level(G_log_ctx, (L)); \ 107 | G_log_level = (L); \ 108 | } while(0) 109 | 110 | #define LOG_INIT(L) \ 111 | do { \ 112 | G_log_ctx = log_new(); \ 113 | log_set_level(G_log_ctx, (L)); \ 114 | G_log_level = (L); \ 115 | } while(0) 116 | 117 | #define LOG_INIT_CONSOLE(X) \ 118 | do { \ 119 | G_log_ctx = log_new(); \ 120 | log_set_level(G_log_ctx, (X)); \ 121 | G_log_level = (X); \ 122 | log_add_output_stream(G_log_ctx, LOG_WARNING, LOG_MAX, NULL, stdout); \ 123 | log_add_output_stream(G_log_ctx, LOG_MIN, LOG_WARNING - 1, NULL, stderr); \ 124 | } while(0) 125 | 126 | #define LOG_FREE log_delete(G_log_ctx) 127 | 128 | #define IS_LOGGABLE(L) (G_log_level >= (L)) 129 | 130 | #define LOG(L, M) \ 131 | do { \ 132 | if(IS_LOGGABLE(L)) { \ 133 | G_log_log_level = (L); \ 134 | log_log_default M; \ 135 | } \ 136 | } while(0) 137 | 138 | 139 | void hex_dump(int level, unsigned char *p, int len); 140 | 141 | #endif 142 | --------------------------------------------------------------------------------