misc cleanup for real release

This commit is contained in:
devinacker 2013-10-22 17:02:37 -04:00
parent 361ee95fac
commit 11a23403bc
9 changed files with 275 additions and 33 deletions

22
.gitattributes vendored Normal file
View file

@ -0,0 +1,22 @@
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain

219
.gitignore vendored Normal file
View file

@ -0,0 +1,219 @@
*.bin
*.exe
*.o
#################
## Eclipse
#################
*.pydevproject
.project
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
#################
## Visual Studio
#################
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
*.ncrunch*
.*crunch*.local.xml
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.Publish.xml
*.pubxml
# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/
# Windows Azure Build Output
csx
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
App_Data/*.mdf
App_Data/*.ldf
#############
## Windows detritus
#############
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Mac crap
.DS_Store
#############
## Python
#############
*.py[co]
# Packages
*.egg
*.egg-info
dist/
build/
eggs/
parts/
var/
sdist/
develop-eggs/
.installed.cfg
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
#Translations
*.mo
#Mr Developer
.mr.developer.cfg

View file

@ -1,4 +0,0 @@
exhal
=====
Compression and decompression tools for NES, SNES, and Game Boy games by HAL Laboratory

View file

@ -81,4 +81,5 @@ Special thanks to:
- andlabs for helping me make the list of supported games - andlabs for helping me make the list of supported games
- BMF54123 for naming the programs - BMF54123 for naming the programs
- Tiiffi for misc. Mac OS X build fixes
- You for downloading (and using?) my software - You for downloading (and using?) my software

View file

@ -3,10 +3,11 @@
by Devin Acker by Devin Acker
This code is released under the terms of the MIT license. This code is released under the terms of the MIT license.
See copying.txt for details. See COPYING.txt for details.
*/ */
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include "compress.h" #include "compress.h"
#ifdef DEBUG_OUT #ifdef DEBUG_OUT
@ -121,27 +122,28 @@ size_t unpack(uint8_t *packed, uint8_t *unpacked) {
switch (command) { switch (command) {
// write uncompressed bytes // write uncompressed bytes
case 0: case 0:
for (int i = 0; i < length; i++) memcpy(&unpacked[outpos], &packed[inpos], length);
unpacked[outpos++] = packed[inpos++];
outpos += length;
inpos += length;
break; break;
// 8-bit RLE // 8-bit RLE
case 1: case 1:
for (int i = 0; i < length; i++) unpacked[outpos] = packed[inpos++];
unpacked[outpos++] = packed[inpos]; memcpy(&unpacked[outpos + 1], &unpacked[outpos], length - 1);
inpos++; outpos += length;
break; break;
// 16-bit RLE // 16-bit RLE
case 2: case 2:
for (int i = 0; i < length; i++) { unpacked[outpos] = packed[inpos];
unpacked[outpos++] = packed[inpos]; unpacked[outpos + 1] = packed[inpos + 1];
unpacked[outpos++] = packed[inpos+1]; memcpy(&unpacked[outpos + 2], &unpacked[outpos], 2 * (length - 1));
}
inpos += 2; outpos += (length * 2);
inpos += 2;
break; break;
// 8-bit increasing sequence // 8-bit increasing sequence
@ -156,13 +158,16 @@ size_t unpack(uint8_t *packed, uint8_t *unpacked) {
// (offset is big-endian) // (offset is big-endian)
case 4: case 4:
case 7: case 7:
// 7 isn't a real method number, but it behaves the same as 4 due to a quirk in how
// the original decompression routine is programmed. (one of Parasyte's docs confirms
// this for GB games as well). let's handle it anyway
command = 4; command = 4;
offset = (packed[inpos] << 8) | packed[inpos+1]; offset = (packed[inpos] << 8) | packed[inpos+1];
for (int i = 0; i < length; i++) memcpy(&unpacked[outpos], &unpacked[offset], length);
unpacked[outpos++] = unpacked[offset + i];
inpos += 2; outpos += length;
inpos += 2;
break; break;
// backref with bit rotation // backref with bit rotation
@ -241,7 +246,7 @@ rle_t rle_check (uint8_t *start, uint8_t *current, uint32_t insize, int fast) {
if (current[size] != current[0]) break; if (current[size] != current[0]) break;
// if this is better than the current candidate, use it // if this is better than the current candidate, use it
if (size > LONG_RUN_SIZE) size = LONG_RUN_SIZE; //if (size > LONG_RUN_SIZE) size = LONG_RUN_SIZE;
if (size > 2 && size > candidate.size) { if (size > 2 && size > candidate.size) {
candidate.size = size; candidate.size = size;
@ -259,7 +264,7 @@ rle_t rle_check (uint8_t *start, uint8_t *current, uint32_t insize, int fast) {
} }
// if this is better than the current candidate, use it // if this is better than the current candidate, use it
if (size > LONG_RUN_SIZE) size = LONG_RUN_SIZE; //if (size > LONG_RUN_SIZE) size = LONG_RUN_SIZE;
if (size > 2 && size > candidate.size) { if (size > 2 && size > candidate.size) {
candidate.size = size; candidate.size = size;
@ -277,7 +282,7 @@ rle_t rle_check (uint8_t *start, uint8_t *current, uint32_t insize, int fast) {
if (current[size] != (current[0] + size)) break; if (current[size] != (current[0] + size)) break;
// if this is better than the current candidate, use it // if this is better than the current candidate, use it
if (size > LONG_RUN_SIZE) size = LONG_RUN_SIZE; //if (size > LONG_RUN_SIZE) size = LONG_RUN_SIZE;
if (size > 2 && size > candidate.size) { if (size > 2 && size > candidate.size) {
candidate.size = size; candidate.size = size;
@ -304,7 +309,7 @@ backref_t ref_search (uint8_t *start, uint8_t *current, uint32_t insize, int fas
if (pos[size] != current[size]) break; if (pos[size] != current[size]) break;
// if this is better than the current candidate, use it // if this is better than the current candidate, use it
if (size > LONG_RUN_SIZE) size = LONG_RUN_SIZE; //if (size > LONG_RUN_SIZE) size = LONG_RUN_SIZE;
if (size > 3 && size > candidate.size) { if (size > 3 && size > candidate.size) {
candidate.size = size; candidate.size = size;
@ -322,7 +327,7 @@ backref_t ref_search (uint8_t *start, uint8_t *current, uint32_t insize, int fas
if (pos[size] != rotate(current[size])) break; if (pos[size] != rotate(current[size])) break;
// if this is better than the current candidate, use it // if this is better than the current candidate, use it
if (size > LONG_RUN_SIZE) size = LONG_RUN_SIZE; //if (size > LONG_RUN_SIZE) size = LONG_RUN_SIZE;
if (size > 3 && size > candidate.size) { if (size > 3 && size > candidate.size) {
candidate.size = size; candidate.size = size;
@ -337,7 +342,7 @@ backref_t ref_search (uint8_t *start, uint8_t *current, uint32_t insize, int fas
if (start[pos - start - size] != current[size]) break; if (start[pos - start - size] != current[size]) break;
// if this is better than the current candidate, use it // if this is better than the current candidate, use it
if (size > LONG_RUN_SIZE) size = LONG_RUN_SIZE; //if (size > LONG_RUN_SIZE) size = LONG_RUN_SIZE;
if (size > 3 && size > candidate.size) { if (size > 3 && size > candidate.size) {
candidate.size = size; candidate.size = size;
@ -456,8 +461,7 @@ uint16_t write_raw (uint8_t *out, uint16_t outpos, uint8_t *in, uint16_t insize)
} }
// write data // write data
for (int i = 0; i < insize; i++) memcpy(&out[outpos], in, insize);
out[outpos++] = in[i];
return outsize; return outsize;
} }

View file

@ -3,7 +3,7 @@
by Devin Acker by Devin Acker
This code is released under the terms of the MIT license. This code is released under the terms of the MIT license.
See copying.txt for details. See COPYING.txt for details.
*/ */
#ifndef _COMPRESS_H #ifndef _COMPRESS_H

View file

@ -6,7 +6,7 @@
exhal romfile offset outfile exhal romfile offset outfile
This code is released under the terms of the MIT license. This code is released under the terms of the MIT license.
See copying.txt for details. See COPYING.txt for details.
*/ */
#include <stdio.h> #include <stdio.h>

View file

@ -7,7 +7,7 @@
inhal -n infile outfile inhal -n infile outfile
This code is released under the terms of the MIT license. This code is released under the terms of the MIT license.
See copying.txt for details. See COPYING.txt for details.
*/ */
#include <stdio.h> #include <stdio.h>

View file

@ -17,15 +17,15 @@ DEFINES += -DEXTRA_OUT
# Uncomment this line to enable debug output # Uncomment this line to enable debug output
#DEFINES += -DDEBUG_OUT #DEFINES += -DDEBUG_OUT
all: inhal$(EXT) exhal$(EXT) all: inhal exhal
clean: clean:
$(DELETE) inhal$(EXT) exhal$(EXT) compress.o $(DELETE) inhal$(EXT) exhal$(EXT) compress.o
inhal$(EXT): inhal.c compress.o inhal: inhal.c compress.o
$(CC) $(DEFINES) $(FLAGS) -o inhal$(EXT) inhal.c compress.o $(CC) $(DEFINES) $(FLAGS) -o inhal$(EXT) inhal.c compress.o
exhal$(EXT): exhal.c compress.o exhal: exhal.c compress.o
$(CC) $(DEFINES) $(FLAGS) -o exhal$(EXT) exhal.c compress.o $(CC) $(DEFINES) $(FLAGS) -o exhal$(EXT) exhal.c compress.o
compress.o: compress.c compress.o: compress.c