-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3bee5fd
commit 867e9b4
Showing
199 changed files
with
9,176 additions
and
790 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,48 @@ | ||
# SSB64ImageFileAppender | ||
# File Appenders | ||
1. SSB64ImageFileAppender - stupid easy appending of images | ||
2. SSB64FileAppender - generic appending of files | ||
|
||
## SSB64ImageFileAppender | ||
A simple tool for appending binary image data to Smash Remix. A lot of this was based off of https://github.com/jordanbarkley/Texture64. | ||
|
||
I didn't bother making the code look nice. It works. | ||
|
||
## Files Currently Supported | ||
### Files Currently Supported | ||
- 0A04 Stage Icons | ||
- 0A05 Character Portraits | ||
|
||
# How to Use | ||
## Stage Icons | ||
### How to Use | ||
#### Stage Icons | ||
1. Grab file 0A04 using the GE Editor and name it 0A04.bin. | ||
2. In the same directory as 0A04.bin, put your stage icon file(s). | ||
3. Drag your stage icon file(s) over StageIconAppender.bat - this will update 0A04.bin. | ||
4. Inject 0A04.bin using the GE Editor. | ||
5. Confirm using GE Editor's Image Tools. | ||
|
||
## Character Portraits | ||
#### Character Portraits | ||
Note: Currently, Remix expects the flash portrait to be immediately after the normal portrait. | ||
1. Grab file 0A05 using the GE Editor and name it 0A05.bin. | ||
2. In the same directory as 0A04.bin, put your character portrait file(s). | ||
2. In the same directory as 0A05.bin, put your character portrait file(s). | ||
3. Drag your character portrait file(s) over CharacterIconAppender.bat - this will update 0A05.bin. | ||
4. Inject 0A05.bin using the GE Editor. | ||
5. Confirm using GE Editor's Image Tools. | ||
5. Confirm using GE Editor's Image Tools. | ||
|
||
## SSB64FileAppender | ||
A simple tool for appending data of any structure to Smash Remix. Loops through the pointers and adjusts them automatically. A lot of this was based off of https://github.com/jordanbarkley/Texture64. | ||
|
||
I didn't bother making the code look nice. It works. | ||
|
||
### How to Use | ||
The sequence of events will look like this: | ||
|
||
1. You replace some data using the GE Setup Editor in some file. | ||
2. You track down the part of the file that has your change. | ||
3. You take note of the offset in the file where your data begins - this is called the originalOffset. | ||
4. You copy the data that you want to append to a new file. | ||
5. You look in the new file for the first pointer (the format is `XXXXYYYY` where `XXXX * 4` is the offset of the next pointer and `YYYY * 4` is the offset of the data that will be converted by the game to a pointer) - this is called the internalFileTableOffset. | ||
6. Most likely, but optionally, you want to append this to an existing file. You need to know the Internal File Table Offset for this file - this is the internalFileTableOffsetTarget. | ||
7. Open a command line and cd to this directory, then call the jar like so: `java -jar ./SSB64FileAppender.jar /path/to/newFile.bin originalOffset internalFileTableOffset /path/to/targetFileToAppendTo.bin internalFileTableOffsetTarget`. | ||
|
||
Example: `java -jar ./SSB64FileAppender.jar "../smashremixprivate/roms/bowser logo.bin" 0xB08 0x6FC "../smashremixprivate/roms/0023-bowser.bin" 0x0004` | ||
|
||
The tool should update all pointers in the internal file linked list and update the last pointer in the original file as well (changing it from 0xFFFF). If there are any external file pointers, you will get a warning message that details where in the file they occurred. You'll have to manually adjust those. Too bad! |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
import java.io.*; | ||
import java.util.Arrays; | ||
import java.nio.file.*; | ||
|
||
public class SSB64FileAppender { | ||
|
||
public static void main(String[] args) { | ||
SSB64FileAppender appender = new SSB64FileAppender(); | ||
if (args.length != 3 && args.length != 5) { | ||
System.out.println("usage: java -jar SSB64FileAppender.jar <path/to/file_containing_new_data> <offset_in_original_file> <internal_file_table_offset> [<path/to/file_to_append> <internal_file_table_offset>]"); | ||
System.exit(0); | ||
} | ||
if (args.length == 3) { | ||
appender.run(args[0], Integer.decode(args[1]), Integer.decode(args[2]), null, null); | ||
} else { | ||
appender.run(args[0], Integer.decode(args[1]), Integer.decode(args[2]), args[3], Integer.decode(args[4])); | ||
} | ||
} | ||
|
||
public void run(String filenameNewData, Integer originalOffset, Integer internalFileTableOffset, String filenameTarget, Integer internalFileTableOffsetTarget) { | ||
byte[] newData = new byte[0]; | ||
int newDataLength = 0; | ||
byte[] existingData = new byte[0]; | ||
int existingDataLength = 0; | ||
byte outArray[] = new byte[0]; | ||
int offset = internalFileTableOffset; | ||
|
||
// this correction value will be applied to all pointers we find | ||
// initially it is the originalOffset, but if a target file is specified we must account for the internal file table offset of that file | ||
int correction = 0 - originalOffset; | ||
|
||
try { | ||
// read data of file to add | ||
newData = Files.readAllBytes(Paths.get(filenameNewData)); | ||
newDataLength = newData.length; | ||
|
||
// read data of file to add to | ||
if (filenameTarget != null) { | ||
existingData = Files.readAllBytes(Paths.get(filenameTarget)); | ||
existingDataLength = existingData.length; | ||
|
||
// correction value needs to be increased by the size of the file | ||
correction += existingDataLength; | ||
|
||
offset += existingDataLength; | ||
} | ||
} catch (IOException e) { | ||
// close when file is not present | ||
System.out.println("File not found!"); | ||
System.exit(0); | ||
|
||
} catch (Exception e) { | ||
// generic error catch | ||
System.out.println("Unknown error occured!"); | ||
System.exit(0); | ||
} | ||
|
||
// combine the files | ||
outArray = new byte[existingDataLength + newDataLength]; | ||
System.arraycopy(existingData, 0, outArray, 0, existingDataLength); | ||
System.arraycopy(newData, 0, outArray, existingDataLength, newDataLength); | ||
|
||
//System.out.println("correction: " + String.format("0x%08X", correction) + " (" + correction + ")"); | ||
|
||
// now loop through file's pointers, updating as we go | ||
// first, update the final pointer in the target file to the first pointer address in the added file | ||
if (filenameTarget != null) { | ||
int offsetTarget = internalFileTableOffsetTarget; | ||
|
||
while (offsetTarget < outArray.length) { | ||
int[] pointers = getPointers(outArray, offsetTarget); | ||
//System.out.println("next: " + String.format("0x%08X", pointers[0]) + ", data: " + String.format("0x%08X", pointers[1])); | ||
|
||
if (pointers[0] == 0xFFFFFFFC) { | ||
outArray[offsetTarget] = (byte) ((offset / 4) >> 8); | ||
outArray[offsetTarget + 0x01] = (byte) (offset / 4); | ||
break; | ||
} | ||
|
||
offsetTarget = pointers[0]; | ||
} | ||
} | ||
// next, update pointers in the new added data | ||
while (offset < outArray.length && offset >= 0) { | ||
int[] pointers = getPointers(outArray, offset); | ||
//System.out.println("next: " + String.format("0x%08X", pointers[0]) + ", data: " + String.format("0x%08X", pointers[1])); | ||
//System.out.println("next: " + String.format("0x%08X", pointers[0] + correction) + ", data: " + String.format("0x%08X", pointers[1] + correction)); | ||
|
||
if ((pointers[0] != 0xFFFFFFFC) && ((pointers[0] + correction) < outArray.length) && ((pointers[0] + correction) >= 0)) { | ||
outArray[offset] = (byte) (((pointers[0] + correction) / 4) >> 8); | ||
outArray[offset + 0x01] = (byte) ((pointers[0] + correction) / 4); | ||
} else { | ||
// if this is the last pointer, set to 0xFFFF | ||
outArray[offset] = (byte) 0xFF; | ||
outArray[offset + 0x01] = (byte) 0xFF; | ||
} | ||
outArray[offset + 0x02] = (byte) (((pointers[1] + correction) / 4) >> 8); | ||
outArray[offset + 0x03] = (byte) ((pointers[1] + correction) / 4); | ||
|
||
if ((pointers[1] - originalOffset) < 0) { | ||
System.out.println("Warning! Data pointer at " + String.format("0x%08X", offset) + " references external offset (before start of added file):" + String.format("0x%08X", pointers[1] + correction)); | ||
} else if ((pointers[1] - originalOffset) >= newDataLength) { | ||
System.out.println("Warning! Data pointer at " + String.format("0x%08X", offset) + " references external offset (after end of added file):" + String.format("0x%08X", pointers[1] + correction)); | ||
} | ||
|
||
if (pointers[0] == 0xFFFFFFFC) { | ||
break; | ||
} | ||
|
||
offset = pointers[0] + correction; | ||
} | ||
|
||
// output the file | ||
try (FileOutputStream fos = new FileOutputStream("./output.bin")) { | ||
fos.write(outArray); | ||
} catch (Exception e) { | ||
System.out.println("Unknown error occured!"); | ||
System.exit(0); | ||
} | ||
} | ||
|
||
public int[] getPointers(byte[] dataArray, int offset) { | ||
//System.out.println("offset: " + String.format("0x%08X", offset)); | ||
//System.out.println("next: " + String.format("0x%02X", dataArray[offset]) + " " + String.format("0x%02X", dataArray[offset + 0x01]) + ", data: " + String.format("0x%08X", dataArray[offset + 0x02]) + " " + String.format("0x%08X", dataArray[offset + 0x03])); | ||
|
||
int nextPointer = (int) (((dataArray[offset] << 8) | (dataArray[offset + 0x01] & 0xFF)) * 4); | ||
int dataPointer = (int) (((dataArray[offset + 0x02] << 8) | (dataArray[offset + 0x03] & 0xFF)) * 4); | ||
|
||
int[] returnVal = {nextPointer, dataPointer}; | ||
|
||
return returnVal; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Manifest-Version: 1.0 | ||
Main-Class: SSB64FileAppender |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
assembler\bass.exe -o "ssb64asm.z64" main.asm -sym logfile.log | ||
assembler\chksum64.exe "ssb64asm.z64" | ||
assembler\rn64crc.exe -u | ||
assembler\chksum64.exe "ssb64asm.z64" > nul | ||
assembler\rn64crc.exe -u > nul | ||
pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.