Skip to content

Commit

Permalink
Merge pull request #1463 from nicolasnoble/nopad
Browse files Browse the repository at this point in the history
Adding nopad option to ps1-packer.
  • Loading branch information
nicolasnoble authored Nov 14, 2023
2 parents a64ba39 + 0e6f33d commit a072e38
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/supportpsx/binffi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ struct BinaryLoaderInfo {
struct PS1PackerOptions {
uint32_t tload;
bool shell;
bool nopad;
bool booty;
bool raw;
bool rom;
Expand Down Expand Up @@ -99,6 +100,7 @@ PCSX.Binary.pack = function(src, dest, addr, pc, gp, sp, options)
opts.tload = options.tload and options.tload or 0
opts.booty = options.booty and true or false
opts.shell = options.shell and true or false
opts.nopad = options.nopad and true or false
opts.raw = options.raw and true or false
opts.rom = options.rom and true or false
opts.cpe = options.cpe and true or false
Expand Down
3 changes: 2 additions & 1 deletion src/supportpsx/ps1-packer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ void PCSX::PS1Packer::pack(IO<File> src, IO<File> dest, uint32_t addr, uint32_t
pushBytes(dataOut, jr(Reg::T0));
pushBytes(dataOut, addiu(Reg::RA, Reg::T8, 0));
}
while (!options.cpe && !options.booty && !options.rom && !options.raw && ((dataOut.size() & 0x7ff) != 0)) {
while (!options.cpe && !options.booty && !options.rom && !options.raw && !options.nopad &&
((dataOut.size() & 0x7ff) != 0)) {
dataOut.push_back(0);
}

Expand Down
1 change: 1 addition & 0 deletions src/supportpsx/ps1-packer.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace PS1Packer {
struct Options {
uint32_t tload = 0;
bool shell = false;
bool nopad = false;
bool booty = false;
bool raw = false;
bool rom = false;
Expand Down
3 changes: 3 additions & 0 deletions tools/ps1-packer/ps1-packer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ ps1-packer by Nicolas "Pixel" Noble
const bool booty = args.get<bool>("booty").value_or(false);
const bool rom = args.get<bool>("rom").value_or(false);
const bool cpe = args.get<bool>("cpe").value_or(false);
const bool nopad = args.get<bool>("nopad").value_or(false);
unsigned outputTypeCount = (raw ? 1 : 0) + (booty ? 1 : 0) + (rom ? 1 : 0) + (cpe ? 1 : 0);
if (asksForHelp || !oneInput || !hasOutput || (outputTypeCount > 1)) {
fmt::print(R"(
Expand All @@ -53,6 +54,7 @@ Usage: {} input.ps-exe [-h] [-tload addr] [-shell] [-raw | -booty | -rom | -cpe]
-h displays this help information and exit.
-tload force loading at this address instead of doing in-place.
-shell adds a kernel reset stub.
-nopad disables padding of the output file to 2048 bytes. Only for PS-EXE output.
These options control the output format, and are mutually exclusive:
-raw outputs a raw file.
Expand Down Expand Up @@ -99,6 +101,7 @@ Valid input binary files can be in the following formats:
options.cpe = cpe;
options.shell = shell;
options.tload = tload;
options.nopad = nopad;
PCSX::IO<PCSX::File> out(new PCSX::PosixFile(output.value().c_str(), PCSX::FileOps::TRUNCATE));
PCSX::PS1Packer::pack(new PCSX::SubFile(memory, memory->lowestAddress(), memory->actualSize()), out,
memory->lowestAddress(), info.pc.value_or(0), info.gp.value_or(0), info.sp.value_or(0),
Expand Down

0 comments on commit a072e38

Please sign in to comment.