Skip to content

Commit 78c8d21

Browse files
committed
gpu: further timing hacks
#711 notaz#348
1 parent 95bcdd3 commit 78c8d21

File tree

4 files changed

+44
-16
lines changed

4 files changed

+44
-16
lines changed

libpcsxcore/database.c

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ static const char * const gpu_slow_llist_db[] =
3232
"SLES01712", "SLPS01525", "SLPS91138", "SLPM87102", "SLUS00823",
3333
/* Crash Bash */
3434
"SCES02834", "SCUS94570", "SCUS94616", "SCUS94654",
35+
/* F1 2000 - aborting/resuming dma in menus */
36+
"SLUS01120", "SLES02722", "SLES02723", "SLES02724", "SLPS02758", "SLPM80564",
3537
/* Final Fantasy IV */
3638
"SCES03840", "SLPM86028", "SLUS01360",
3739
/* Point Blank - calibration cursor */
@@ -54,12 +56,6 @@ static const char * const gpu_centering_hack_db[] =
5456
"SLPM86009",
5557
};
5658

57-
static const char * const dualshock_timing1024_hack_db[] =
58-
{
59-
/* Judge Dredd - could also be poor cdrom+mdec+dma timing */
60-
"SLUS00630", "SLES00755",
61-
};
62-
6359
static const char * const dualshock_init_analog_hack_db[] =
6460
{
6561
/* Formula 1 Championship Edition */
@@ -109,7 +105,6 @@ hack_db[] =
109105
HACK_ENTRY(cdr_read_timing, cdr_read_hack_db),
110106
HACK_ENTRY(gpu_slow_list_walking, gpu_slow_llist_db),
111107
HACK_ENTRY(gpu_centering, gpu_centering_hack_db),
112-
HACK_ENTRY(gpu_timing1024, dualshock_timing1024_hack_db),
113108
HACK_ENTRY(dualshock_init_analog, dualshock_init_analog_hack_db),
114109
HACK_ENTRY(fractional_Framerate, fractional_Framerate_hack_db),
115110
HACK_ENTRY(f1, f1_hack_db),
@@ -157,6 +152,22 @@ cycle_multiplier_overrides[] =
157152
{ 200, { "SLUS01519", "SCPS45260", "SLPS01463" } },
158153
};
159154

155+
static const struct
156+
{
157+
int cycles;
158+
const char * const id[4];
159+
}
160+
gpu_timing_hack_db[] =
161+
{
162+
/* Judge Dredd - poor cdrom+mdec+dma+gpu timing */
163+
{ 1024, { "SLUS00630", "SLES00755" } },
164+
/* F1 2000 - flooding the GPU in menus */
165+
{ 300*1024, { "SLUS01120", "SLES02722", "SLES02723", "SLES02724" } },
166+
{ 300*1024, { "SLPS02758", "SLPM80564" } },
167+
/* Soul Blade - same as above */
168+
{ 512*1024, { "SLUS00240", "SCES00577" } },
169+
};
170+
160171
static const char * const lightrec_hack_db[] =
161172
{
162173
/* Tomb Raider (Rev 2) - boot menu clears over itself */
@@ -223,6 +234,22 @@ void Apply_Hacks_Cdrom(void)
223234
}
224235
}
225236

237+
Config.gpu_timing_override = 0;
238+
for (i = 0; i < ARRAY_SIZE(gpu_timing_hack_db); i++)
239+
{
240+
const char * const * const ids = gpu_timing_hack_db[i].id;
241+
for (j = 0; j < ARRAY_SIZE(gpu_timing_hack_db[i].id); j++)
242+
if (ids[j] && strcmp(ids[j], CdromId) == 0)
243+
break;
244+
if (j < ARRAY_SIZE(gpu_timing_hack_db[i].id))
245+
{
246+
Config.gpu_timing_override = gpu_timing_hack_db[i].cycles;
247+
SysPrintf("using gpu_timing_override: %d\n",
248+
Config.gpu_timing_override);
249+
break;
250+
}
251+
}
252+
226253
if (drc_is_lightrec()) {
227254
lightrec_hacks = 0;
228255
if (Config.hacks.f1)

libpcsxcore/psxcommon.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ typedef struct {
145145
boolean TurboCD;
146146
int cycle_multiplier; // 100 for 1.0
147147
int cycle_multiplier_override;
148+
int gpu_timing_override;
148149
s8 GpuListWalking;
149150
s8 FractionalFramerate; // ~49.75 and ~59.81 instead of 50 and 60
150151
u8 Cpu; // CPU_DYNAREC or CPU_INTERPRETER
@@ -154,7 +155,6 @@ typedef struct {
154155
boolean gpu_slow_list_walking;
155156
boolean gpu_centering;
156157
boolean dualshock_init_analog;
157-
boolean gpu_timing1024;
158158
boolean fractional_Framerate;
159159
boolean f1;
160160
} hacks;

libpcsxcore/psxdma.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,11 @@ void psxDma2(u32 madr, u32 bcr, u32 chcr) { // GPU
192192
case 0x01000401: // dma chain
193193
PSXDMA_LOG("*** DMA 2 - GPU dma chain *** %lx addr = %lx size = %lx\n", chcr, madr, bcr);
194194
// when not emulating walking progress, end immediately
195+
// (some games abort the dma and read madr so break out of that logic)
195196
madr_next = 0xffffff;
196197

197198
do_walking = Config.GpuListWalking;
198-
if (do_walking < 0 || Config.hacks.gpu_timing1024)
199+
if (do_walking < 0)
199200
do_walking = Config.hacks.gpu_slow_list_walking;
200201
madr_next_p = do_walking ? &madr_next : NULL;
201202

@@ -204,9 +205,9 @@ void psxDma2(u32 madr, u32 bcr, u32 chcr) { // GPU
204205

205206
HW_DMA2_MADR = SWAPu32(madr_next);
206207

207-
// a hack for Judge Dredd which is annoyingly sensitive to timing
208-
if (Config.hacks.gpu_timing1024)
209-
cycles_sum = 1024;
208+
// timing hack with some lame heuristics
209+
if (Config.gpu_timing_override && (do_walking || cycles_sum > 64))
210+
cycles_sum = Config.gpu_timing_override;
210211

211212
psxRegs.gpuIdleAfter = psxRegs.cycle + cycles_sum + cycles_last_cmd;
212213
set_event(PSXINT_GPUDMA, cycles_sum);
@@ -238,7 +239,7 @@ void gpuInterrupt() {
238239
psxRegs.gpuIdleAfter = psxRegs.cycle + cycles_sum + cycles_last_cmd;
239240
set_event(PSXINT_GPUDMA, cycles_sum);
240241
//printf("%u dma2cn: %6ld,%4d %08x\n", psxRegs.cycle, cycles_sum,
241-
// cycles_last_cmd, HW_DMA2_MADR);
242+
// cycles_last_cmd, HW_DMA2_MADR);
242243
return;
243244
}
244245
if (HW_DMA2_CHCR & SWAP32(0x01000000))

plugins/gpulib/gpu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -831,10 +831,8 @@ long GPUdmaChain(uint32_t *rambase, uint32_t start_addr,
831831
}
832832
}
833833

834-
if (progress_addr) {
835-
*progress_addr = addr;
834+
if (progress_addr && (cpu_cycles_last + cpu_cycles_sum > 512))
836835
break;
837-
}
838836
if (addr == ld_addr) {
839837
log_anomaly(&gpu, "GPUdmaChain: loop @ %08x, cnt=%u\n", addr, count);
840838
break;
@@ -851,6 +849,8 @@ long GPUdmaChain(uint32_t *rambase, uint32_t start_addr,
851849
gpu.state.last_list.cycles = cpu_cycles_sum + cpu_cycles_last;
852850
gpu.state.last_list.addr = start_addr;
853851

852+
if (progress_addr)
853+
*progress_addr = addr;
854854
*cycles_last_cmd = cpu_cycles_last;
855855
return cpu_cycles_sum;
856856
}

0 commit comments

Comments
 (0)