Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
allkern committed Aug 5, 2024
1 parent 875c9be commit 5916b49
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 87 deletions.
2 changes: 1 addition & 1 deletion build-win64.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ gcc -I"$($PSX_DIR)" `
-m64 -lSDL2main -lSDL2 -Wno-overflow `
-Wall -pedantic -DLOG_USE_COLOR `
-Wno-address-of-packed-member `
-ffast-math -Ofast -g -flto
-ffast-math -Ofast -g -flto -Werror

Copy-Item -Path "$($SDL2_DIR)\bin\SDL2.dll" -Destination "bin"
2 changes: 1 addition & 1 deletion compat.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Not working:
Fixed: Aconcagua (Japan) (Disc 1) *6
Fixed: Animetic Story Game 1 - Card Captor Sakura (Japan) (Disc 1) *1 (2989bb6)
Ape Escape (USA) *21
Fixed: Ape Escape (USA) *21 (0=10000h CDROM DMA BS)
Fixed: Blade (USA) *3
CTR - Crash Team Racing (USA) *16 (regression)
Fixed: Crash Bash (USA) *1 (2989bb6)
Expand Down
50 changes: 1 addition & 49 deletions psx/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ void psx_cpu_cycle(psx_cpu_t* cpu) {
int cyc = psx_cpu_execute(cpu);

if (!cyc) {
printf("psxe: Illegal instruction %08x at %08x (next=%08x, saved=%08x)\n", cpu->opcode, cpu->next_pc, cpu->saved_pc);
printf("psxe: Illegal instruction %08x at %08x (next=%08x, saved=%08x)\n", cpu->opcode, cpu->pc, cpu->next_pc, cpu->saved_pc);

psx_cpu_exception(cpu, CAUSE_RI);
}
Expand Down Expand Up @@ -534,18 +534,6 @@ static inline void psx_cpu_i_lui(psx_cpu_t* cpu) {
cpu->r[T] = IMM16 << 16;
}

static inline void psx_cpu_i_cop1(psx_cpu_t* cpu) {
DO_PENDING_LOAD;

psx_cpu_exception(cpu, CAUSE_CPU);
}

static inline void psx_cpu_i_cop3(psx_cpu_t* cpu) {
DO_PENDING_LOAD;

psx_cpu_exception(cpu, CAUSE_CPU);
}

static inline void psx_cpu_i_lb(psx_cpu_t* cpu) {
TRACE_M("lb");

Expand Down Expand Up @@ -1807,42 +1795,6 @@ static inline void psx_gte_i_invalid(psx_cpu_t* cpu) {
R_GC2 = gte_clamp_rgb(cpu, 2, R_MAC2 >> 4); \
R_BC2 = gte_clamp_rgb(cpu, 3, R_MAC3 >> 4); }

static inline void gte_interpolate_color(psx_cpu_t* cpu, int64_t mac1, int64_t mac2, int64_t mac3) {
R_MAC1 = gte_clamp_mac(cpu, 1, (I64(R_RFC) << 12) - mac1);
R_MAC2 = gte_clamp_mac(cpu, 2, (I64(R_GFC) << 12) - mac2);
R_MAC3 = gte_clamp_mac(cpu, 3, (I64(R_BFC) << 12) - mac3);

// printf("input=(%08x, %08x, %08x) (%d, %d, %d) mac=(%08x, %08x, %08x), (%d, %d, %d) fc=(%08x, %08x, %08x)\n",
// mac1,
// mac2,
// mac3,
// mac1,
// mac2,
// mac3,
// R_MAC1,
// R_MAC2,
// R_MAC3,
// R_MAC1,
// R_MAC2,
// R_MAC3,
// I64(R_RFC) << 12,
// I64(R_GFC) << 12,
// I64(R_BFC) << 12
// );

R_IR1 = gte_clamp_ir(cpu, 1, R_MAC1, 0);
R_IR2 = gte_clamp_ir(cpu, 2, R_MAC2, 0);
R_IR3 = gte_clamp_ir(cpu, 3, R_MAC3, 0);

R_MAC1 = gte_clamp_mac(cpu, 1, (R_IR1 * R_IR0) + mac1);
R_MAC2 = gte_clamp_mac(cpu, 2, (R_IR2 * R_IR0) + mac2);
R_MAC3 = gte_clamp_mac(cpu, 3, (R_IR3 * R_IR0) + mac3);

R_IR1 = gte_clamp_ir(cpu, 1, R_MAC1, cpu->gte_sf);
R_IR2 = gte_clamp_ir(cpu, 2, R_MAC2, cpu->gte_sf);
R_IR3 = gte_clamp_ir(cpu, 3, R_MAC3, cpu->gte_sf);
}

static inline void psx_gte_i_rtps(psx_cpu_t* cpu) {
R_FLAG = 0;
GTE_RTP_DQ(0);
Expand Down
17 changes: 9 additions & 8 deletions psx/dev/cdrom/cdrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,6 @@ void psx_cdrom_update(psx_cdrom_t* cdrom, int cycles) {
if (cdrom->state == CD_STATE_READ) {
cdrom_process_setloc(cdrom);

int ts = psx_disc_query(cdrom->disc, cdrom->lba);

cdrom->state = CD_STATE_READ;
cdrom->prev_state = CD_STATE_READ;
cdrom->delay = CD_DELAY_ONGOING_READ;
Expand All @@ -534,8 +532,6 @@ void psx_cdrom_update(psx_cdrom_t* cdrom, int cycles) {
if (cdrom->state == CD_STATE_READ) {
cdrom_process_setloc(cdrom);

int ts = psx_disc_query(cdrom->disc, cdrom->lba);

cdrom->state = CD_STATE_READ;
cdrom->prev_state = CD_STATE_READ;
cdrom->delay = CD_DELAY_ONGOING_READ;
Expand Down Expand Up @@ -586,7 +582,10 @@ uint32_t psx_cdrom_read8(psx_cdrom_t* cdrom, uint32_t addr) {
case 2: return cdrom_read_data(cdrom);
case 3: return (cdrom->index & 1) ? (0xe0 | cdrom->ifr) : cdrom->ier;
}

return 0;
}

void psx_cdrom_write8(psx_cdrom_t* cdrom, uint32_t addr, uint32_t value) {
switch ((cdrom->index << 2) | addr) {
case 0: cdrom_write_stat(cdrom, value); break;
Expand Down Expand Up @@ -707,11 +706,13 @@ void cdrom_write_vapp(psx_cdrom_t* cdrom, uint8_t data) {
}

uint32_t psx_cdrom_read32(psx_cdrom_t* cdrom, uint32_t addr) {
assert(("32-bit CDROM reads are not supported", 0));
assert("32-bit CDROM reads are not supported" && 0);

return 0;
}

uint32_t psx_cdrom_read16(psx_cdrom_t* cdrom, uint32_t addr) {
assert(("16-bit CDROM reads are not supported", 0));
assert("16-bit CDROM reads are not supported" && 0);

// The CDROM controller is connected to the SUB-BUS which is a 16-bit
// bus, but the output from the controller itself is 8-bit. I think
Expand All @@ -720,9 +721,9 @@ uint32_t psx_cdrom_read16(psx_cdrom_t* cdrom, uint32_t addr) {
}

void psx_cdrom_write32(psx_cdrom_t* cdrom, uint32_t addr, uint32_t value) {
assert(("32-bit CDROM writes are not supported", 0));
assert("32-bit CDROM writes are not supported" && 0);
}

void psx_cdrom_write16(psx_cdrom_t* cdrom, uint32_t addr, uint32_t value) {
assert(("16-bit CDROM writes are not supported", 0));
assert("16-bit CDROM writes are not supported" && 0);
}
18 changes: 9 additions & 9 deletions psx/dev/cdrom/cue.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,8 +530,8 @@ int cue_read(cue_t* cue, uint32_t lba, void* buf) {
// then we are being requested a pregap sector. Clear buffer
// and initialize sync data (not actually needed)
if (!track) {
memset(buf, 0, 2352);
memset(buf + 1, 255, 10);
memset((uint8_t*)buf, 0, 2352);
memset((uint8_t*)buf + 1, 255, 10);

return TS_PREGAP;
}
Expand All @@ -548,7 +548,7 @@ int cue_read(cue_t* cue, uint32_t lba, void* buf) {
// );

if (file->buf_mode == LD_BUFFERED) {
uint8_t* ptr = file->buf + ((lba - file->start) * 2352);
uint8_t* ptr = (uint8_t*)file->buf + ((lba - file->start) * 2352);

memcpy(buf, ptr, 2352);
} else {
Expand Down Expand Up @@ -584,10 +584,10 @@ int cue_get_track_lba(cue_t* cue, int track) {

void cue_init_disc(cue_t* cue, psx_disc_t* disc) {
disc->udata = cue;
disc->read_sector = cue_read;
disc->query_sector = cue_query;
disc->get_track_number = cue_get_track_number;
disc->get_track_count = cue_get_track_count;
disc->get_track_lba = cue_get_track_lba;
disc->destroy = cue_destroy;
disc->read_sector = (read_sector_func)cue_read;
disc->query_sector = (query_sector_func)cue_query;
disc->get_track_number = (get_track_number_func)cue_get_track_number;
disc->get_track_count = (get_track_count_func)cue_get_track_count;
disc->get_track_lba = (get_track_lba_func)cue_get_track_lba;
disc->destroy = (destroy_func)cue_destroy;
}
7 changes: 2 additions & 5 deletions psx/dev/cdrom/impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,6 @@ void cdrom_cmd_gettd(psx_cdrom_t* cdrom) {

int mm = f / (60 * 75);
int ss = (f % (60 * 75)) / 75;
int ff = (f % (60 * 75)) % 75;

// printf("gettd: track %u lba=%08x (%u) %02u:%02u:%02u\n",
// track,
Expand All @@ -536,9 +535,7 @@ void cdrom_cmd_seekl(psx_cdrom_t* cdrom) {
cdrom_set_int(cdrom, 3);
queue_push(cdrom->response, cdrom_get_stat(cdrom));

int ts = psx_disc_query(cdrom->disc, cdrom->pending_lba);

cdrom->delay = CD_DELAY_1MS; // cdrom_get_seek_delay(cdrom, ts);
cdrom->delay = CD_DELAY_1MS;
cdrom->state = CD_STATE_TX_RESP2;
} else {
int ts = psx_disc_query(cdrom->disc, cdrom->pending_lba);
Expand Down Expand Up @@ -577,7 +574,7 @@ void cdrom_cmd_seekp(psx_cdrom_t* cdrom) {
cdrom_set_int(cdrom, 3);
queue_push(cdrom->response, cdrom_get_stat(cdrom));

cdrom->delay = CD_DELAY_1MS; // cdrom_get_seek_delay(cdrom, ts);
cdrom->delay = CD_DELAY_1MS;
cdrom->state = CD_STATE_TX_RESP2;
cdrom->busy = 1;
} else {
Expand Down
20 changes: 7 additions & 13 deletions psx/dev/spu.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

#define VOICE_COUNT 24

static float interpolate_hermite(float a, float b, float c, float d, float t) {
float x = -a/2.0f + (3.0f*b)/2.0f - (3.0f*c)/2.0f + d/2.0f;
float y = a - (5.0f*b)/2.0f + 2.0f*c - d / 2.0f;
float z = -a/2.0f + c/2.0f;
float w = b;
// static float interpolate_hermite(float a, float b, float c, float d, float t) {
// float x = -a/2.0f + (3.0f*b)/2.0f - (3.0f*c)/2.0f + d/2.0f;
// float y = a - (5.0f*b)/2.0f + 2.0f*c - d / 2.0f;
// float z = -a/2.0f + c/2.0f;
// float w = b;

return (x*t*t*t) + (y*t*t) + (z*t) + w;
}
// return (x*t*t*t) + (y*t*t) + (z*t) + w;
// }

static const int g_spu_pos_adpcm_table[] = {
0, +60, +115, +98, +122
Expand Down Expand Up @@ -572,7 +572,6 @@ void spu_get_reverb_sample(psx_spu_t* spu, int inl, int inr, int* outl, int* out
uint32_t psx_spu_get_sample(psx_spu_t* spu) {
spu->even_cycle ^= 1;

int active_voice_count = 0;
int left = 0;
int right = 0;
int revl = 0;
Expand All @@ -587,8 +586,6 @@ uint32_t psx_spu_get_sample(psx_spu_t* spu) {

spu_handle_adsr(spu, v);

++active_voice_count;

uint32_t sample_index = spu->data[v].counter >> 12;

if (sample_index > 27) {
Expand Down Expand Up @@ -681,9 +678,6 @@ uint32_t psx_spu_get_sample(psx_spu_t* spu) {
spu->data[v].counter += step;
}

// if (!active_voice_count)
// return 0x00000000;

int16_t clamprl = CLAMP(revl, INT16_MIN, INT16_MAX);
int16_t clamprr = CLAMP(revr, INT16_MIN, INT16_MAX);
int16_t clampsl = CLAMP(left, INT16_MIN, INT16_MAX);
Expand Down
2 changes: 1 addition & 1 deletion psx/psx.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ double psx_get_display_aspect(psx_t* psx) {
return aspect;
}

void atcons_tx(void* udata, char c) {
void atcons_tx(void* udata, unsigned char c) {
putchar(c);
}

Expand Down

0 comments on commit 5916b49

Please sign in to comment.