From 0e6f33d3ac2082f52726da5c33fdb79316b12239 Mon Sep 17 00:00:00 2001 From: Nicolas Pixel Noble Date: Tue, 14 Nov 2023 11:04:56 -0800 Subject: [PATCH] Adding nopad option to ps1-packer. --- src/supportpsx/binffi.lua | 2 ++ src/supportpsx/ps1-packer.cc | 3 ++- src/supportpsx/ps1-packer.h | 1 + tools/ps1-packer/ps1-packer.cc | 3 +++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/supportpsx/binffi.lua b/src/supportpsx/binffi.lua index 6d1c096b4..6d0b96d67 100644 --- a/src/supportpsx/binffi.lua +++ b/src/supportpsx/binffi.lua @@ -37,6 +37,7 @@ struct BinaryLoaderInfo { struct PS1PackerOptions { uint32_t tload; bool shell; + bool nopad; bool booty; bool raw; bool rom; @@ -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 diff --git a/src/supportpsx/ps1-packer.cc b/src/supportpsx/ps1-packer.cc index 0b112cb3c..cc2daae0e 100644 --- a/src/supportpsx/ps1-packer.cc +++ b/src/supportpsx/ps1-packer.cc @@ -171,7 +171,8 @@ void PCSX::PS1Packer::pack(IO src, IO 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); } diff --git a/src/supportpsx/ps1-packer.h b/src/supportpsx/ps1-packer.h index 02e677ab2..cac49ade1 100644 --- a/src/supportpsx/ps1-packer.h +++ b/src/supportpsx/ps1-packer.h @@ -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; diff --git a/tools/ps1-packer/ps1-packer.cc b/tools/ps1-packer/ps1-packer.cc index 7451b346e..33cfa42eb 100644 --- a/tools/ps1-packer/ps1-packer.cc +++ b/tools/ps1-packer/ps1-packer.cc @@ -44,6 +44,7 @@ ps1-packer by Nicolas "Pixel" Noble const bool booty = args.get("booty").value_or(false); const bool rom = args.get("rom").value_or(false); const bool cpe = args.get("cpe").value_or(false); + const bool nopad = args.get("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"( @@ -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. @@ -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 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),