This repository has been archived by the owner on Mar 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmain.c
505 lines (405 loc) · 17.4 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
/*
GTA Native Resolution Patch
Copyright (C) 2019, TheFloW
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <pspsdk.h>
#include <pspkernel.h>
#include <pspge.h>
#include <pspgu.h>
#include <stdio.h>
#include <string.h>
#include <systemctrl.h>
PSP_MODULE_INFO("GTANativeResolution", 0, 1, 0);
// TODO: fix street lamp flickering
// TODO: fix rays (look at the scene in lcs after Toni steps out of the bus)
// TODO: fix small savedata screen
// TODO: fix multiplayer character position and size in vcs
// TODO: fix multiplayer character highlight in lcs
#define MAKE_CALL(a, f) _sw(0x0C000000 | (((u32)(f) >> 2) & 0x03FFFFFF), a);
#define MAKE_JUMP(a, f) _sw(0x08000000 | (((u32)(f) & 0x0FFFFFFC) >> 2), a);
#define HIJACK_FUNCTION(a, f, ptr) \
{ \
u32 _func_ = a; \
static u32 patch_buffer[3]; \
_sw(_lw(_func_), (u32)patch_buffer); \
_sw(_lw(_func_ + 4), (u32)patch_buffer + 8);\
MAKE_JUMP((u32)patch_buffer + 4, _func_ + 8); \
_sw(0x08000000 | (((u32)(f) >> 2) & 0x03FFFFFF), _func_); \
_sw(0, _func_ + 4); \
ptr = (void *)patch_buffer; \
}
#define DRAW_NATIVE 0x4BCDEF00
#define PITCH 960
#define WIDTH 960
#define HEIGHT 544
#define PIXELFORMAT 0
#define DISPLAY_BUFFER 0x0A400000
#define GE_LIST 0x0A500000
#define GE_LIST_SIZE 0x00100000
#define VRAM 0x04000000
#define VRAM_DRAW_BUFFER_OFFSET 0
#define VRAM_DEPTH_BUFFER_OFFSET 0x00100000
#define BACKUP_BUFFER 0x0A700000
#define CUSTOM_GE_LIST 0x0A800000
#define TEXTURE_MODE_CMD 0xC8D00002 // original: 0xC8000002
STMOD_HANDLER previous;
void sceGuEnd(unsigned int *list);
u32 *ge_list_offset, *texture_buffer;
u32 ge_list_1_offset, ge_list_2_offset;
int (* initGu)(int mode, int pixelformat, int width, int height, int pitch);
int initGuPatched(int mode, int pixelformat, int width, int height, int pitch) {
*(u32 *)DRAW_NATIVE = 1;
return initGu(0, PIXELFORMAT, WIDTH, HEIGHT, PITCH);
}
void (* drawDisplay)();
void drawDisplayPatched() {
*(u32 *)(ge_list_1_offset + 4) = CUSTOM_GE_LIST;
*(u32 *)(ge_list_2_offset + 4) = CUSTOM_GE_LIST;
sceGuStart(0, (void *)CUSTOM_GE_LIST);
sceGuTexSync();
sceGuTexImage(0, 0, 0, 0, (void *)VRAM);
sceGuEnable(GU_DITHER);
sceGuCopyImage(PIXELFORMAT, 0, 0, WIDTH, HEIGHT, PITCH,
(void *)(0x40000000 | (VRAM + VRAM_DRAW_BUFFER_OFFSET)),
0, 0, PITCH, (void *)(0x40000000 | DISPLAY_BUFFER));
sceGuTexSync();
sceGuFinish();
}
void setTexture(u32 *list, void *buffer) {
sceGuStart(0, (void *)*list);
sceGuTexImage(0, 512, 512, PITCH, buffer);
sceGuEnd(list);
}
void (* drawTexture)(u32 *list, int x0, int y0, int u0, int v0, int x1, int y1, int u1, int v1, int z);
void drawTexturePatched(u32 *list, int x0, int y0, int u0, int v0, int x1, int y1, int u1, int v1, int z) {
int top = 0;
int bottom = 960 * 272 * 2;
int left = 144 * 2;
int right = 480 * 2;
sceGuStart(0, (void *)*list);
sceGuCopyImage(0, 0, 0, 64, 64, 64,
(void *)(0x40000000 | (VRAM + VRAM_DEPTH_BUFFER_OFFSET)),
0, 0, 64, (void *)(0x40000000 | BACKUP_BUFFER));
sceGuTexSync();
sceGuDrawBuffer(0, (void *)VRAM_DEPTH_BUFFER_OFFSET, 64);
sceGuEnd(list);
setTexture(list, (void *)(VRAM + VRAM_DRAW_BUFFER_OFFSET + top + left));
drawTexture(list, 00, 00, 0, 0, 32, 32, 320, 272, 0);
setTexture(list, (void *)(VRAM + VRAM_DRAW_BUFFER_OFFSET + top + right));
drawTexture(list, 32, 00, 0, 0, 64, 32, 320, 272, 0);
setTexture(list, (void *)(VRAM + VRAM_DRAW_BUFFER_OFFSET + bottom + left));
drawTexture(list, 00, 32, 0, 0, 32, 64, 320, 272, 0);
setTexture(list, (void *)(VRAM + VRAM_DRAW_BUFFER_OFFSET + bottom + right));
drawTexture(list, 32, 32, 0, 0, 64, 64, 320, 272, 0);
}
void drawTexture2Patched(u32 *list, int x0, int y0, int u0, int v0, int x1, int y1, int u1, int v1, int z) {
drawTexture(list, x0, y0, u0, v0, x1, y1, u1, v1, z);
sceGuStart(0, (void *)*list);
sceGuTexSync();
sceGuCopyImage(0, 0, 0, 64, 64, 64,
(void *)(0x40000000 | (VRAM + VRAM_DEPTH_BUFFER_OFFSET)),
0, 0, 64, (void *)(0x40000000 | *texture_buffer));
sceGuTexSync();
sceGuCopyImage(0, 0, 0, 64, 64, 64,
(void *)(0x40000000 | BACKUP_BUFFER),
0, 0, 64, (void *)(0x40000000 | (VRAM + VRAM_DEPTH_BUFFER_OFFSET)));
sceGuTexSync();
sceGuEnd(list);
}
// Affects the sky too
int (* drawReflection)(int a0);
int drawReflectionPatched(int a0) {
sceGuStart(0, (void *)*ge_list_offset);
sceGuEnable(GU_DITHER);
sceGuEnd(ge_list_offset);
int res = drawReflection(a0);
sceGuStart(0, (void *)*ge_list_offset);
sceGuDisable(GU_DITHER);
sceGuEnd(ge_list_offset);
return res;
}
#define FPS_VAR 0x4BCDEF04
SceInt64 cur_micros = 0, delta_micros = 0, last_micros = 0;
u32 frames = 0;
float fps = 0.0f;
SceInt64 sceKernelGetSystemTimeWidePatched(void) {
SceInt64 cur_micros = sceKernelGetSystemTimeWide();
if (cur_micros >= (last_micros + 1000000)) {
delta_micros = cur_micros - last_micros;
last_micros = cur_micros;
fps = (frames / (double)delta_micros) * 1000000.0f;
memcpy((void *)FPS_VAR, &fps, 4);
frames = 0;
}
frames++;
return cur_micros;
}
// ULUS10160
void PatchVCS(u32 text_addr) {
// gp: 0x003ADD60
texture_buffer = (u32 *)(text_addr + 0x003A9850);
ge_list_offset = (u32 *)(text_addr + 0x003C3370);
ge_list_1_offset = text_addr + 0x00672200;
ge_list_2_offset = text_addr + 0x006719C0;
// Redirect vram offsets
u32 store_draw_buffer = _lw(text_addr + 0x00202B18);
u32 store_depth_buffer = _lw(text_addr + 0x00202B24);
_sw(0x3C170000 | (VRAM_DRAW_BUFFER_OFFSET >> 16), text_addr + 0x00202B18);
_sw(0x36F70000 | (VRAM_DRAW_BUFFER_OFFSET & 0xFFFF), text_addr + 0x00202B1C);
_sw(store_draw_buffer, text_addr + 0x00202B20); // draw buffer
_sw(0x3C060000 | (VRAM_DEPTH_BUFFER_OFFSET >> 16), text_addr + 0x00202B24);
_sw(0x34C60000 | (VRAM_DEPTH_BUFFER_OFFSET & 0xFFFF), text_addr + 0x00202B28);
_sw(store_depth_buffer, text_addr + 0x00202B2C); // depth buffer
// Redirect GE list
u32 store_ge_list_buffer = _lw(text_addr + 0x00202CA8);
u32 store_ge_list_2_buffer = _lw(text_addr + 0x00202CB8);
_sw(0x3C040000 | (GE_LIST >> 16), text_addr + 0x00202CA0);
_sw(0x34840000 | (GE_LIST & 0xFFFF), text_addr + 0x00202CA4);
_sw(store_ge_list_buffer, text_addr + 0x00202CA8);
_sw(0x3C040000 | ((GE_LIST + GE_LIST_SIZE) >> 16), text_addr + 0x00202CAC);
_sw(0x34840000 | ((GE_LIST + GE_LIST_SIZE) & 0xFFFF), text_addr + 0x00202CB0);
_sw(0x03E00008, text_addr + 0x00202CB4);
_sw(store_ge_list_2_buffer, text_addr + 0x00202CB8);
_sw(0x3C050000 | (GE_LIST_SIZE >> 16), text_addr + 0x00202EB0);
_sw(0x34A50000 | (GE_LIST_SIZE & 0xFFFF), text_addr + 0x00202EB4);
// Patch GU init
HIJACK_FUNCTION(text_addr + 0x002029DC, initGuPatched, initGu);
// Patch draw display
HIJACK_FUNCTION(text_addr + 0x00203C0C, drawDisplayPatched, drawDisplay);
// Fix map scissoring
// map
_sw(0x34060000 | 960, text_addr + 0x00177924);
_sw(0x34070000 | 448, text_addr + 0x0017793C);
// legend box
_sw(0x34060000 | 960, text_addr + 0x00177BCC);
_sw(0x34070000 | 448, text_addr + 0x00177BD4);
// Fix loading bar proportion
_sw(0x34040000 | 512, text_addr + 0x00131494);
_sw(0x34040000 | 512, text_addr + 0x00131558);
_sw(0x34040000 | 512, text_addr + 0x001315D8);
_sw(0x34040000 | 512, text_addr + 0x00131664);
_sw(0x34040000 | 320, text_addr + 0x001314AC);
_sw(0x34050000 | 320, text_addr + 0x00131568);
_sw(0x34050000 | 320, text_addr + 0x001315E8);
_sw(0x34040000 | 320, text_addr + 0x00131674);
// Fix aim gun
_sw(0x3C0941E0, text_addr + 0x0021461C); // size
_sw(0x3C0A43F0, text_addr + 0x00214624); // x
_sw(0x3C0B4388, text_addr + 0x00214628); // y
// Fix rocket launcher aim size
_sh(0x4296, text_addr + 0x001BCC44);
// Fix aim unknown
_sw(0x3C0440C0, text_addr + 0x001BCFC4); // size
_sw(0x3C0443F0, text_addr + 0x001BCFCC); // x
_sw(0x3C044388, text_addr + 0x001BCFDC); // y
_sw(0x3C044334, text_addr + 0x001BCFE4); // unknown
// Fix aim sniper
_sw(0x3C0543F0, text_addr + 0x001BD13C); // x
_sw(0x3C054388, text_addr + 0x001BD148); // y
_sw(0x3C054334, text_addr + 0x001BD154); // unknown
_sw(0x3C054180, text_addr + 0x001BD170); // size
// Fix ray proportion. TODO
_sw(0x34040000 | 512, text_addr + 0x002A4400);
_sw(0x34040000 | 320, text_addr + 0x002A4424);
// Fix pager proportions
_sw(0x34040000 | 512, text_addr + 0x001b8974);
_sw(0x34040000 | 512, text_addr + 0x001b89e4);
_sw(0x34040000 | 320, text_addr + 0x001b89f8);
// Fix pager text placement
_sw(0x34040000 | 512, text_addr + 0x001b8b40);
_sw(0x34050000 | 320, text_addr + 0x001b8b44);
// Fix reflection
_sh(PIXELFORMAT, text_addr + 0x00277EBC);
_sh(PITCH, text_addr + 0x00277F2C);
drawTexture = (void *)(text_addr + 0x000DBA08);
MAKE_CALL(text_addr + 0x00277FE0, drawTexturePatched);
MAKE_CALL(text_addr + 0x00278304, drawTexture2Patched);
HIJACK_FUNCTION(text_addr + 0x00157BA4, drawReflectionPatched, drawReflection);
// Patch mipmap level mode
_sh(TEXTURE_MODE_CMD >> 16, text_addr + 0x000014AC);
_sh(TEXTURE_MODE_CMD & 0xFFFF, text_addr + 0x000014B0);
_sh(TEXTURE_MODE_CMD >> 16, text_addr + 0x00155398);
_sh(TEXTURE_MODE_CMD & 0xFFFF, text_addr + 0x0015539C);
_sh(TEXTURE_MODE_CMD >> 16, text_addr + 0x002769E4);
_sh(TEXTURE_MODE_CMD & 0xFFFF, text_addr + 0x002769E8);
_sh(TEXTURE_MODE_CMD >> 16, text_addr + 0x002785FC);
_sh(TEXTURE_MODE_CMD & 0xFFFF, text_addr + 0x0027860C);
MAKE_CALL(text_addr + 0x002030D4, sceKernelGetSystemTimeWidePatched);
// Cap to 20FPS
// _sh(3, text_addr + 0x002030B4);
}
// ULUS10041
void PatchLCS(u32 text_addr) {
texture_buffer = (u32 *)(text_addr + 0x00354AC0);
ge_list_offset = (u32 *)(text_addr + 0x0038ACD0);
ge_list_1_offset = text_addr + 0x00659340;
ge_list_2_offset = text_addr + 0x00658B00;
// Redirect vram offsets
u32 store_draw_buffer = _lw(text_addr + 0x002B0100);
u32 store_depth_buffer = _lw(text_addr + 0x002B010C);
_sw(0x3C090000 | (VRAM_DRAW_BUFFER_OFFSET >> 16), text_addr + 0x002B0100);
_sw(0x35290000 | (VRAM_DRAW_BUFFER_OFFSET & 0xFFFF), text_addr + 0x002B0104);
_sw(store_draw_buffer, text_addr + 0x002B0108); // draw buffer
_sw(0x3C060000 | (VRAM_DEPTH_BUFFER_OFFSET >> 16), text_addr + 0x002B010C);
_sw(0x34C60000 | (VRAM_DEPTH_BUFFER_OFFSET & 0xFFFF), text_addr + 0x002B0110);
_sw(store_depth_buffer, text_addr + 0x002B0114); // depth buffer
// Redirect GE list
_sw(0x3C040000 | (GE_LIST >> 16), text_addr + 0x002AEEC0);
_sw(0x34840000 | (GE_LIST & 0xFFFF), text_addr + 0x002AEEC4);
_sw(0x3C060000 | (GE_LIST_SIZE >> 16), text_addr + 0x002AEECC);
_sw(0x24C60000 | (GE_LIST_SIZE & 0xFFFF), text_addr + 0x002AEED4);
_sw(0x3C050000 | (GE_LIST_SIZE >> 16), text_addr + 0x002AF124);
_sw(0x34A50000 | (GE_LIST_SIZE & 0xFFFF), text_addr + 0x002AF128);
// Patch GU init
HIJACK_FUNCTION(text_addr + 0x002AFF64, initGuPatched, initGu);
// Patch draw display
HIJACK_FUNCTION(text_addr + 0x002B02F8, drawDisplayPatched, drawDisplay);
// Fix maps cursor
_sw(0x34040000 | 272, text_addr + 0x002d6fc8);
_sw(0x34050000 | 272, text_addr + 0x002d711c);
_sw(0x34040000 | 272, text_addr + 0x002d72a4);
_sw(0x34040000 | 272, text_addr + 0x002d741c);
_sw(0x34040000 | 272, text_addr + 0x002d7548);
_sw(0x34050000 | 272, text_addr + 0x002d76b8);
_sw(0x34040000 | 272, text_addr + 0x002d77a4);
_sw(0x34040000 | 272, text_addr + 0x002d77b0);
_sw(0x34040000 | 272, text_addr + 0x002d77f4);
_sw(0x34040000 | 272, text_addr + 0x002d7928);
_sw(0x34050000 | 272, text_addr + 0x002d7ba4);
_sw(0x34040000 | 272, text_addr + 0x002d7c90);
_sw(0x34040000 | 272, text_addr + 0x002d7c9c);
_sw(0x34040000 | 272, text_addr + 0x002d7ce0);
_sw(0x34050000 | 272, text_addr + 0x002d7ec8);
_sw(0x34040000 | 272, text_addr + 0x002d7f4c);
_sw(0x34040000 | 272, text_addr + 0x002d80c0);
_sw(0x34040000 | 272, text_addr + 0x002d8140);
_sw(0x34050000 | 272, text_addr + 0x002d858c);
_sw(0x34050000 | 272, text_addr + 0x002d8644);
_sw(0x34040000 | 480, text_addr + 0x002d6fb0);
_sw(0x34040000 | 480, text_addr + 0x002d7110);
_sw(0x34040000 | 480, text_addr + 0x002d7118);
_sw(0x34040000 | 480, text_addr + 0x002d728c);
_sw(0x34040000 | 480, text_addr + 0x002d7404);
_sw(0x34040000 | 480, text_addr + 0x002d7530);
_sw(0x34040000 | 480, text_addr + 0x002d76b4);
_sw(0x34040000 | 480, text_addr + 0x002d7830);
_sw(0x34040000 | 480, text_addr + 0x002d7870);
_sw(0x34040000 | 480, text_addr + 0x002d7910);
_sw(0x34040000 | 480, text_addr + 0x002d7ba0);
_sw(0x34040000 | 480, text_addr + 0x002d7d1c);
_sw(0x34040000 | 480, text_addr + 0x002d7d5c);
_sw(0x34050000 | 480, text_addr + 0x002d82a8);
_sw(0x34040000 | 480, text_addr + 0x002d832c);
_sw(0x34040000 | 480, text_addr + 0x002d8494);
_sw(0x34040000 | 480, text_addr + 0x002d8514);
_sw(0x34040000 | 480, text_addr + 0x002d8588);
_sw(0x34040000 | 480, text_addr + 0x002d8640);
// Fix maps cursor
_sw(0x34040000 | 272, text_addr + 0x002e0158);
_sw(0x34040000 | 480, text_addr + 0x002e0198);
_sw(0x34040000 | 480, text_addr + 0x002e01f8);
// Fix map background size
_sw(0x34050000 | 272, text_addr + 0x002db7b0);
_sw(0x34050000 | 272, text_addr + 0x002db860);
_sw(0x34040000 | 480, text_addr + 0x002DB7A8);
_sw(0x34040000 | 480, text_addr + 0x002DB858);
// Fix radio station icons in menu
_sw(0x34040000 | 480, text_addr + 0x002dedbc);
_sw(0x34040000 | 480, text_addr + 0x002df0b4);
// Fix Stats
_sw(0x34050000 | 480, text_addr + 0x002DF9F0); //values
_sw(0x34050000 | 480, text_addr + 0x002DFC2C); //rating value
_sw(0x34040000 | 480, text_addr + 0x002DFC50); //rating name
// Fix map scissoring
_sw(0x24E7FFA0, text_addr + 0x002DB808);
_sw(0x24E7FFA0, text_addr + 0x002DB8B8);
// Fix loading bar proportion
_sw(0x34040000 | 512, text_addr + 0x001BDC04);
_sw(0x34040000 | 512, text_addr + 0x001BDCD0);
_sw(0x34040000 | 512, text_addr + 0x001BDD5C);
_sw(0x34040000 | 512, text_addr + 0x001BDDE0);
_sw(0x34040000 | 320, text_addr + 0x001BDC28);
_sw(0x34050000 | 320, text_addr + 0x001BDCE0);
_sw(0x34050000 | 320, text_addr + 0x001BDD6C);
_sw(0x34040000 | 320, text_addr + 0x001BDDF0);
// Fix aim gun
_sw(0x3C0941E0, text_addr + 0x000657A0); // size
_sw(0x3C0A43F0, text_addr + 0x000657A8); // x
_sw(0x3C0B4388, text_addr + 0x000657AC); // y
// Fix rocket launcher aim size
_sh(0x4296, text_addr + 0x00185318);
// Fix aim unknown
_sw(0x3C0440C0, text_addr + 0x00185614); // size
_sw(0x3C0443F0, text_addr + 0x0018561C); // x
_sw(0x3C044388, text_addr + 0x0018562C); // y
_sw(0x3C044334, text_addr + 0x00185634); // unknown
// Fix aim sniper
_sw(0x3C0543F0, text_addr + 0x00185790); // x
_sw(0x3C054388, text_addr + 0x0018579C); // y
_sw(0x3C054334, text_addr + 0x001857A8); // unknown
_sw(0x3C054180, text_addr + 0x001857C4); // size
// Fix ray scissoring
_sw(0x34050000 | 1024, text_addr + 0x00149ff0);
_sw(0x34050000 | 640, text_addr + 0x0014a004);
_sw(0x34050000 | 1024, text_addr + 0x0014a040);
_sw(0x34050000 | 640, text_addr + 0x0014a054);
// Fix ray scissoring
_sw(0x34040000 | 1024, text_addr + 0x002CC930);
_sw(0x34050000 | 640, text_addr + 0x002CC938);
// Fix ray proportion
_sw(0x34040000 | 512, text_addr + 0x00221ad4);
_sw(0x34040000 | 320, text_addr + 0x00221afc);
// Fix proportion (health plus)
_sw(0x34050200, text_addr + 0x002d5b60);
_sw(0x34040200, text_addr + 0x002d5b84);
_sw(0x34050140, text_addr + 0x002d5ba4);
_sw(0x34040140, text_addr + 0x002d5bc8);
// Fix reflection
_sh(PIXELFORMAT, text_addr + 0x002A7644);
_sh(PITCH, text_addr + 0x002A76B8);
drawTexture = (void *)(text_addr + 0x0027AE00);
MAKE_CALL(text_addr + 0x002A776C, drawTexturePatched);
MAKE_CALL(text_addr + 0x002A7ABC, drawTexture2Patched);
HIJACK_FUNCTION(text_addr + 0x002C5104, drawReflectionPatched, drawReflection);
// Patch mipmap level mode
_sh(TEXTURE_MODE_CMD >> 16, text_addr + 0x000B0AD0);
_sh(TEXTURE_MODE_CMD & 0xFFFF, text_addr + 0x000B0AD4);
_sh(TEXTURE_MODE_CMD >> 16, text_addr + 0x00150AEC);
_sh(TEXTURE_MODE_CMD & 0xFFFF, text_addr + 0x00150AF0);
_sh(TEXTURE_MODE_CMD >> 16, text_addr + 0x002A6350);
_sh(TEXTURE_MODE_CMD & 0xFFFF, text_addr + 0x002A6354);
_sh(TEXTURE_MODE_CMD >> 16, text_addr + 0x002A7DC4);
_sh(TEXTURE_MODE_CMD & 0xFFFF, text_addr + 0x002A7DD4);
MAKE_CALL(text_addr + 0x002AF398, sceKernelGetSystemTimeWidePatched);
// Cap to 20FPS
// _sh(3, text_addr + 0x002AF378);
}
int OnModuleStart(SceModule2 *mod) {
char *modname = mod->modname;
u32 text_addr = mod->text_addr;
if (strcmp(modname, "GTA3") == 0) {
if (strcmp((char *)(text_addr + 0x00307F54), "GTA3") == 0) {
PatchLCS(text_addr);
} else if (strcmp((char *)(text_addr + 0x0036F8D8), "GTA3") == 0) {
PatchVCS(text_addr);
}
sceKernelDcacheWritebackAll();
}
if (!previous)
return 0;
return previous(mod);
}
int module_start() {
previous = sctrlHENSetStartModuleHandler(OnModuleStart);
return 0;
}