diff --git a/src/guest/dreamcast.c b/src/guest/dreamcast.c index 97deb76d..02745f32 100644 --- a/src/guest/dreamcast.c +++ b/src/guest/dreamcast.c @@ -70,6 +70,32 @@ void dc_suspend(struct dreamcast *dc) { dc->running = 0; } +static int dc_load_bin(struct dreamcast *dc, const char *path) { + FILE *fp = fopen(path, "rb"); + if (!fp) { + return 0; + } + + fseek(fp, 0, SEEK_END); + int size = ftell(fp); + fseek(fp, 0, SEEK_SET); + + /* load to 0x0c010000 (area 3) which is where 1ST_READ.BIN is loaded to */ + uint8_t *data = memory_translate(dc->memory, "system ram", 0x00010000); + int n = (int)fread(data, sizeof(uint8_t), size, fp); + fclose(fp); + + if (n != size) { + LOG_WARNING("failed to read %s", path); + return 0; + } + + sh4_reset(dc->sh4, 0x0c010000); + dc_resume(dc); + + return 1; +} + static int dc_load_disc(struct dreamcast *dc, const char *path) { struct disc *disc = disc_create(path); @@ -94,7 +120,7 @@ int dc_load(struct dreamcast *dc, const char *path) { LOG_INFO("loading %s", path); - if (dc_load_disc(dc, path)) { + if (dc_load_disc(dc, path) || dc_load_bin(dc, path)) { return 1; } diff --git a/src/guest/gdrom/gdrom.c b/src/guest/gdrom/gdrom.c index 6fe98433..71ca5912 100644 --- a/src/guest/gdrom/gdrom.c +++ b/src/guest/gdrom/gdrom.c @@ -681,7 +681,9 @@ void gdrom_dma_begin(struct gdrom *gd) { } int gdrom_widescreen_enabled(struct gdrom *gd) { - CHECK_NOTNULL(gd->disc); + if (!gd->disc) { + return 0; + } return patch_widescreen_enabled(gd->disc->id); }