Skip to content

Commit 9c11535

Browse files
committed
Merge branch 'master' into libretro
2 parents 7625ec4 + 78c8d21 commit 9c11535

14 files changed

+224
-140
lines changed

frontend/libretro.c

+10-17
Original file line numberDiff line numberDiff line change
@@ -2140,7 +2140,7 @@ static void update_variables(bool in_flight)
21402140
{
21412141
axis_bounds_modifier = true;
21422142
}
2143-
else if (strcmp(var.value, "circle") == 0)
2143+
else
21442144
{
21452145
axis_bounds_modifier = false;
21462146
}
@@ -2864,26 +2864,19 @@ static uint16_t get_analog_button(int16_t ret, retro_input_state_t input_state_c
28642864
return button;
28652865
}
28662866

2867-
unsigned char axis_range_modifier(int16_t axis_value, bool is_square)
2867+
static unsigned char axis_range_modifier(int axis_value, bool is_square)
28682868
{
2869-
float modifier_axis_range = 0;
2869+
int modifier_axis_range;
28702870

28712871
if (is_square)
2872-
{
2873-
modifier_axis_range = round((axis_value >> 8) / 0.785) + 128;
2874-
if (modifier_axis_range < 0)
2875-
{
2876-
modifier_axis_range = 0;
2877-
}
2878-
else if (modifier_axis_range > 255)
2879-
{
2880-
modifier_axis_range = 255;
2881-
}
2882-
}
2872+
modifier_axis_range = roundf((axis_value >> 8) / 0.785f) + 128;
28832873
else
2884-
{
2885-
modifier_axis_range = MIN(((axis_value >> 8) + 128), 255);
2886-
}
2874+
modifier_axis_range = (axis_value >> 8) + 128;
2875+
2876+
if (modifier_axis_range < 0)
2877+
modifier_axis_range = 0;
2878+
else if (modifier_axis_range > 255)
2879+
modifier_axis_range = 255;
28872880

28882881
return modifier_axis_range;
28892882
}

frontend/libretro_core_options.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ struct retro_core_option_v2_definition option_defs_us[] = {
909909
{ "square", "Square" },
910910
{ NULL, NULL },
911911
},
912-
"circle",
912+
"square",
913913
},
914914
{
915915
"pcsx_rearmed_vibration",

libpcsxcore/cdrom.c

-1
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,6 @@ void cdrInterrupt(void) {
931931
error = ERROR_BAD_ARGNUM;
932932
goto set_error;
933933
}
934-
cdr.DriveState = DRIVESTATE_STANDBY;
935934
second_resp_time = cdReadTime * 125 / 2;
936935
start_rotating = 1;
937936
break;

libpcsxcore/database.c

+34-7
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

+1-1
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

+8-7
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,13 +205,13 @@ 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);
213-
//printf("%u dma2cf: %6d,%4d %08x %08x %08x %08x\n", psxRegs.cycle,
214+
//printf("%u dma2cf: %6ld,%4d %08x %08x %08x %08x\n", psxRegs.cycle,
214215
// cycles_sum, cycles_last_cmd, madr, bcr, chcr, HW_DMA2_MADR);
215216
return;
216217

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

plugins/gpu_neon/psx_gpu/psx_gpu.c

+24-12
Original file line numberDiff line numberDiff line change
@@ -1935,7 +1935,7 @@ setup_blocks_uv_adj_hack(psx_gpu_struct *psx_gpu, block_struct *block,
19351935

19361936
#define setup_blocks_add_blocks_direct() \
19371937
stats_add(texel_blocks_untextured, span_num_blocks); \
1938-
span_pixel_blocks += span_num_blocks \
1938+
stats_add(span_pixel_blocks, span_num_blocks); \
19391939

19401940

19411941
#define setup_blocks_builder(shading, texturing, dithering, sw, target) \
@@ -2918,9 +2918,9 @@ char *render_block_flag_strings[] =
29182918
(triangle_winding_##winding << 6)) \
29192919

29202920
static int prepare_triangle(psx_gpu_struct *psx_gpu, vertex_struct *vertexes,
2921-
vertex_struct *vertexes_out[3])
2921+
prepared_triangle *triangle_out)
29222922
{
2923-
s32 y_top, y_bottom;
2923+
s32 y_top, y_bottom, offset_x, offset_y, i;
29242924
s32 triangle_area;
29252925
u32 triangle_winding = 0;
29262926

@@ -2955,6 +2955,7 @@ static int prepare_triangle(psx_gpu_struct *psx_gpu, vertex_struct *vertexes,
29552955

29562956
y_bottom = c->y;
29572957
y_top = a->y;
2958+
offset_y = sign_extend_11bit(y_top + psx_gpu->offset_y) - y_top;
29582959

29592960
if((y_bottom - y_top) >= 512)
29602961
{
@@ -2982,29 +2983,39 @@ static int prepare_triangle(psx_gpu_struct *psx_gpu, vertex_struct *vertexes,
29822983
vertex_swap(a, b);
29832984
}
29842985

2985-
if((c->x - psx_gpu->offset_x) >= 1024 || (c->x - a->x) >= 1024)
2986+
if(c->x - a->x >= 1024)
29862987
{
29872988
#ifdef PROFILE
29882989
trivial_rejects++;
29892990
#endif
29902991
return 0;
29912992
}
29922993

2993-
if(invalidate_texture_cache_region_viewport(psx_gpu, a->x, y_top, c->x,
2994-
y_bottom) == 0)
2994+
offset_x = sign_extend_11bit(a->x + psx_gpu->offset_x) - a->x;
2995+
if(invalidate_texture_cache_region_viewport(psx_gpu,
2996+
a->x + offset_x, y_top + offset_y,
2997+
c->x + offset_x, y_bottom + offset_y) == 0)
29952998
{
29962999
#ifdef PROFILE
29973000
trivial_rejects++;
29983001
#endif
29993002
return 0;
30003003
}
30013004

3005+
for (i = 0; i < 3; i++)
3006+
{
3007+
vertexes[i].x += offset_x;
3008+
vertexes[i].y += offset_y;
3009+
}
3010+
30023011
psx_gpu->triangle_area = triangle_area;
30033012
psx_gpu->triangle_winding = triangle_winding;
30043013

3005-
vertexes_out[0] = a;
3006-
vertexes_out[1] = b;
3007-
vertexes_out[2] = c;
3014+
triangle_out->vertexes[0] = a;
3015+
triangle_out->vertexes[1] = b;
3016+
triangle_out->vertexes[2] = c;
3017+
triangle_out->offset_x = offset_x;
3018+
triangle_out->offset_y = offset_y;
30083019

30093020
return 1;
30103021
}
@@ -3157,9 +3168,9 @@ static void render_triangle_p(psx_gpu_struct *psx_gpu,
31573168
void render_triangle(psx_gpu_struct *psx_gpu, vertex_struct *vertexes,
31583169
u32 flags)
31593170
{
3160-
vertex_struct *vertex_ptrs[3];
3161-
if (prepare_triangle(psx_gpu, vertexes, vertex_ptrs))
3162-
render_triangle_p(psx_gpu, vertex_ptrs, flags);
3171+
prepared_triangle triangle;
3172+
if (prepare_triangle(psx_gpu, vertexes, &triangle))
3173+
render_triangle_p(psx_gpu, triangle.vertexes, flags);
31633174
}
31643175

31653176
#if !defined(NEON_BUILD) || defined(SIMD_BUILD)
@@ -5067,6 +5078,7 @@ void initialize_psx_gpu(psx_gpu_struct *psx_gpu, u16 *vram)
50675078
psx_gpu->dither_table[1] = dither_table_row(2, -2, 3, -1);
50685079
psx_gpu->dither_table[2] = dither_table_row(-3, 1, -4, 0);
50695080
psx_gpu->dither_table[3] = dither_table_row(3, -1, 2, -2);
5081+
psx_gpu->allow_dithering = 1;
50705082

50715083
psx_gpu->primitive_type = PRIMITIVE_TYPE_UNKNOWN;
50725084

plugins/gpu_neon/psx_gpu/psx_gpu.h

+11-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
#define unlikely(x) __builtin_expect((x), 0)
3333
#endif
3434

35+
#define sign_extend_11bit(value) \
36+
(((s32)((value) << 21)) >> 21)
37+
3538
typedef enum
3639
{
3740
PRIMITIVE_TYPE_TRIANGLE = 0,
@@ -215,7 +218,7 @@ typedef struct
215218

216219
// Align up to 64 byte boundary to keep the upcoming buffers cache line
217220
// aligned, also make reachable with single immediate addition
218-
u8 reserved_a[184 + 8*4 - 9*sizeof(void *)];
221+
u8 reserved_a[180 + 9*4 - 9*sizeof(void *)];
219222

220223
// 8KB
221224
block_struct blocks[MAX_BLOCKS_PER_ROW];
@@ -247,6 +250,13 @@ typedef struct __attribute__((aligned(16)))
247250
u32 padding;
248251
} vertex_struct;
249252

253+
typedef struct
254+
{
255+
vertex_struct *vertexes[3];
256+
s16 offset_x;
257+
s16 offset_y;
258+
} prepared_triangle;
259+
250260
void render_block_fill(psx_gpu_struct *psx_gpu, u32 color, u32 x, u32 y,
251261
u32 width, u32 height);
252262
void render_block_copy(psx_gpu_struct *psx_gpu, u16 *source, u32 x, u32 y,

plugins/gpu_neon/psx_gpu/psx_gpu_main.c

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
#include "SDL.h"
1919
#include "common.h"
2020

21+
#include "../../gpulib/gpu.h"
22+
#include "psx_gpu.c"
23+
#include "psx_gpu_parse.c"
24+
25+
#pragma GCC diagnostic ignored "-Wunused-result"
26+
2127
extern u32 span_pixels;
2228
extern u32 span_pixel_blocks;
2329
extern u32 spans;

0 commit comments

Comments
 (0)