Improve stability

This commit is contained in:
allkern
2023-12-20 11:46:22 -03:00
parent 5b22040640
commit 9ddca2f9ec
7 changed files with 29 additions and 12 deletions
+1
View File
@@ -11,6 +11,7 @@ test/
bios/
roms/
snap/
*.BIN
*.bin
*.dll
*.exe
+4
View File
@@ -72,6 +72,10 @@ void psxe_cfg_init(psxe_config_t* cfg) {
memset(cfg, 0, sizeof(psxe_config_t));
}
void psxe_cfg_destroy(psxe_config_t* cfg) {
free(cfg);
}
void psxe_cfg_load_defaults(psxe_config_t* cfg) {
cfg->bios = NULL;
cfg->bios_search = "bios";
+2
View File
@@ -91,6 +91,8 @@ int main(int argc, const char* argv[]) {
psx_load_exe(psx, cfg->exe);
}
psxe_cfg_destroy(cfg);
while (psxe_screen_is_open(screen)) {
psx_update(psx);
}
+5 -3
View File
@@ -346,6 +346,9 @@ void gpu_render_triangle(psx_gpu_t* gpu, vertex_t v0, vertex_t v1, vertex_t v2,
}
void gpu_render_rect(psx_gpu_t* gpu, rect_data_t data) {
if ((data.v0.x >= 1024) || (data.v0.y >= 512))
return;
uint16_t width, height;
switch ((data.attrib >> 3) & 3) {
@@ -394,9 +397,8 @@ void gpu_render_rect(psx_gpu_t* gpu, rect_data_t data) {
if (!texel)
goto skip;
if (transp) {
if (transp)
transp = (texel & 0x8000) != 0;
}
int tr = ((texel >> 0 ) & 0x1f) << 3;
int tg = ((texel >> 5 ) & 0x1f) << 3;
@@ -802,7 +804,7 @@ void gpu_rect(psx_gpu_t* gpu) {
if (textured && raw)
rect.v0.c = 0x808080;
gpu_render_rect(gpu, rect);
gpu->state = GPU_STATE_RECV_CMD;
+1 -1
View File
@@ -190,7 +190,7 @@ void mdec_decode_macroblock(psx_mdec_t* mdec) {
size_t block_size = (mdec->output_depth == 3) ? 512 : 768;
size_t size = block_size;
ptrdiff_t bytes_processed = 0;
unsigned long bytes_processed = 0;
int block_count = 1;
-1
View File
@@ -427,7 +427,6 @@ void psx_spu_write8(psx_spu_t* spu, uint32_t offset, uint8_t value) {
}
void psx_spu_destroy(psx_spu_t* spu) {
printf("psx_spu_destroy called\n");
free(spu->ram);
free(spu);
}
+16 -7
View File
@@ -68,7 +68,16 @@ static const char* g_psxd_cue_tokens[] = {
void cue_add_track(psxd_cue_t* cue) {
++cue->num_tracks;
cue->track = realloc(cue->track, cue->num_tracks * sizeof(cue_track_t*));
cue_track_t** new_track = realloc(cue->track, cue->num_tracks * sizeof(cue_track_t*));
if (!new_track) {
printf("Fatal error: Couldn't allocate a new CUE track\n");
exit(1);
}
cue->track = new_track;
cue->track[cue->num_tracks - 1] = malloc(sizeof(cue_track_t));
memset(cue->track[cue->num_tracks - 1], 0, sizeof(cue_track_t));
@@ -218,13 +227,13 @@ int cue_parse(psxd_cue_t* cue, FILE* file) {
return cue->error;
int track = atoi(cue->buf) - 1;
if (track != cue->num_tracks)
ERROR_OUT(PE_NON_SEQUENTIAL_TRACKS);
cue_add_track(cue);
cue->track[track]->filename = malloc(strlen(cue->current_file));
cue->track[track]->filename = malloc(strlen(cue->current_file) + 1);
// Copy current file to track filename
strcpy(cue->track[track]->filename, cue->current_file);
@@ -313,16 +322,16 @@ char* cue_get_directory(const char* path) {
}
int psxd_cue_load(psxd_cue_t* cue, const char* path) {
log_fatal("Parsing CUE...");
FILE* file = fopen(path, "rb");
if (ferror(file) || !file) {
fclose(file);
if (!file) {
log_fatal("Couldn't open file \'%s\'", path);
return 1;
}
log_fatal("Parsing CUE...");
if (cue_parse(cue, file)) {
log_fatal("CUE error %s (%u)",
g_psxd_cue_errors[cue->error],