mirror of
https://github.com/captain-amygdala/pistorm.git
synced 2026-01-24 03:06:58 +00:00
Update config_file.h, emulator.c, and amiga-platform.c
This commit is contained in:
parent
b100315fc3
commit
e4c00f2d33
@ -81,6 +81,7 @@ struct platform_config {
|
||||
|
||||
int (*platform_initial_setup)(struct emulator_config *cfg);
|
||||
void (*handle_reset)(struct emulator_config *cfg);
|
||||
void (*shutdown)(struct emulator_config *cfg);
|
||||
void (*setvar)(char *var, char *val);
|
||||
};
|
||||
|
||||
|
||||
@ -161,6 +161,10 @@ void sigint_handler(int sig_num) {
|
||||
if (mem_fd)
|
||||
close(mem_fd);
|
||||
|
||||
if (cfg->platform->shutdown) {
|
||||
cfg->platform->shutdown(cfg);
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@ char *z3_autoconf_zap_id = "^3_autoconf_fast";
|
||||
extern const char *op_type_names[OP_TYPE_NUM];
|
||||
extern uint8_t cdtv_mode;
|
||||
extern uint8_t rtc_type;
|
||||
extern unsigned char cdtv_sram[32 * SIZE_KILO];
|
||||
|
||||
#define min(a, b) (a < b) ? a : b
|
||||
#define max(a, b) (a > b) ? a : b
|
||||
@ -213,6 +214,15 @@ int setup_platform_amiga(struct emulator_config *cfg) {
|
||||
}
|
||||
|
||||
adjust_ranges_amiga(cfg);
|
||||
|
||||
if (cdtv_mode) {
|
||||
FILE *in = fopen("data/cdtv.sram", "rb");
|
||||
if (in != NULL) {
|
||||
printf("Loaded CDTV SRAM.\n");
|
||||
fread(cdtv_sram, 32 * SIZE_KILO, 1, in);
|
||||
fclose(in);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -256,6 +266,21 @@ void handle_reset_amiga(struct emulator_config *cfg) {
|
||||
adjust_ranges_amiga(cfg);
|
||||
}
|
||||
|
||||
void shutdown_platform_amiga(struct emulator_config *cfg) {
|
||||
if (cfg) {}
|
||||
if (cdtv_mode) {
|
||||
FILE *out = fopen("data/cdtv.sram", "wb+");
|
||||
if (out != NULL) {
|
||||
printf("Saving CDTV SRAM.\n");
|
||||
fwrite(cdtv_sram, 32 * SIZE_KILO, 1, out);
|
||||
fclose(out);
|
||||
}
|
||||
else {
|
||||
printf("Failed to write CDTV SRAM to disk.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void create_platform_amiga(struct platform_config *cfg, char *subsys) {
|
||||
cfg->register_read = handle_register_read_amiga;
|
||||
cfg->register_write = handle_register_write_amiga;
|
||||
@ -263,6 +288,7 @@ void create_platform_amiga(struct platform_config *cfg, char *subsys) {
|
||||
cfg->custom_write = custom_write_amiga;
|
||||
cfg->platform_initial_setup = setup_platform_amiga;
|
||||
cfg->handle_reset = handle_reset_amiga;
|
||||
cfg->shutdown = shutdown_platform_amiga;
|
||||
|
||||
cfg->setvar = setvar_amiga;
|
||||
cfg->id = PLATFORM_AMIGA;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user