@@ -79,7 +79,7 @@ int16_t getLO(uint32_t v) {
79
79
80
80
void PCSX::PS1Packer::pack (IO<File> src, IO<File> dest, uint32_t addr, uint32_t pc, uint32_t gp, uint32_t sp,
81
81
const Options& options) {
82
- constexpr size_t stubSize = 7 * 4 ;
82
+ constexpr size_t stubSize = 12 * 4 ;
83
83
std::vector<uint8_t > dataIn;
84
84
dataIn.resize (src->size ());
85
85
src->read (dataIn.data (), dataIn.size ());
@@ -134,7 +134,9 @@ void PCSX::PS1Packer::pack(IO<File> src, IO<File> dest, uint32_t addr, uint32_t
134
134
// to be the same as our tload address, so we need to inject
135
135
// a jump to the start of our code. We are doing this in
136
136
// a fully position-independent way, so raw files can be
137
- // loaded anywhere in memory.
137
+ // loaded anywhere in memory. We're also going to ensure
138
+ // that we're jumping to a segment where the i-cache is
139
+ // enabled, so the decompressor code can run fast.
138
140
auto offset = newPC - 4 * 4 ;
139
141
std::vector<uint8_t > stub;
140
142
if (options.resetstack ) {
@@ -145,9 +147,14 @@ void PCSX::PS1Packer::pack(IO<File> src, IO<File> dest, uint32_t addr, uint32_t
145
147
pushBytes (stub, lui (Reg::T1, getHI (offset)));
146
148
pushBytes (stub, bgezal (Reg::R0, 4 ));
147
149
pushBytes (stub, addiu (Reg::T1, Reg::T1, getLO (offset)));
150
+ pushBytes (stub, lui (Reg::T0, 0x1fff ));
151
+ pushBytes (stub, ori (Reg::T0, Reg::T0, 0xffff ));
152
+ pushBytes (stub, andd (Reg::RA, Reg::RA, Reg::T0));
153
+ pushBytes (stub, lui (Reg::T0, 0x8000 ));
154
+ pushBytes (stub, orr (Reg::RA, Reg::RA, Reg::T0));
148
155
pushBytes (stub, addu (Reg::T0, Reg::RA, Reg::T1));
149
156
pushBytes (stub, jr (Reg::T0));
150
- pushBytes (stub, addiu (Reg::A0, Reg::RA, 12 ));
157
+ pushBytes (stub, addiu (Reg::A0, Reg::RA, 32 ));
151
158
152
159
assert (stub.size () == stubSize);
153
160
0 commit comments