+ if CHKVAR("hdd1") {
+ if (val && strlen(val) != 0)
+ set_hard_drive_image_file_amiga(1, val);
+ }
+ if CHKVAR("cdtv") {
+ printf("[AMIGA] CDTV mode enabled.\n");
+ cdtv_mode = 1;
+ }
+ if (CHKVAR("rtg") && !rtg_enabled) {
+ if (init_rtg_data(cfg)) {
+ printf("[AMIGA] RTG Enabled.\n");
+ rtg_enabled = 1;
+ adjust_ranges_amiga(cfg);
+ }
+ else
+ printf("[AMIGA} Failed to enable RTG.\n");
+ }
+ if CHKVAR("kick13") {
+ printf("[AMIGA] Kickstart 1.3 mode enabled, Z3 PICs will not be enumerated.\n");
+ kick13_mode = 1;
+ }
+ if CHKVAR("a314") {
+ int32_t res = a314_init();
+ if (res != 0) {
+ printf("[AMIGA] Failed to enable A314 emulation, error return code: %d.\n", res);
+ } else {
+ printf("[AMIGA] A314 emulation enabled.\n");
+ add_z2_pic(ACTYPE_A314, 0);
+ a314_emulation_enabled = 1;
+ }
+ }
+ if CHKVAR("a314_conf") {
+ if (val && strlen(val) != 0) {
+ a314_set_config_file(val);
+ }
+ }
+
+ // PiSCSI stuff
+ if (CHKVAR("piscsi") && !piscsi_enabled) {
+ printf("[AMIGA] PISCSI Interface Enabled.\n");
+ piscsi_enabled = 1;
+ piscsi_init();
+ add_z2_pic(ACTYPE_PISCSI, 0);
+ adjust_ranges_amiga(cfg);
+ }
+ if (piscsi_enabled) {
+ if CHKVAR("piscsi0") {
+ piscsi_map_drive(val, 0);
+ }
+ if CHKVAR("piscsi1") {
+ piscsi_map_drive(val, 1);
+ }
+ if CHKVAR("piscsi2") {
+ piscsi_map_drive(val, 2);
+ }
+ if CHKVAR("piscsi3") {
+ piscsi_map_drive(val, 3);
+ }
+ if CHKVAR("piscsi4") {
+ piscsi_map_drive(val, 4);
+ }
+ if CHKVAR("piscsi5") {
+ piscsi_map_drive(val, 5);
+ }
+ if CHKVAR("piscsi6") {
+ piscsi_map_drive(val, 6);
+ }
+ }
+
+ // Pi-Net stuff
+ if (CHKVAR("pi-net")&& !pinet_enabled) {
+ printf("[AMIGA] PI-NET Interface Enabled.\n");
+ pinet_enabled = 1;
+ pinet_init(val);
+ adjust_ranges_amiga(cfg);
+ }
+
+ if CHKVAR("no-pistorm-dev") {
+ pistorm_dev_enabled = 0;
+ printf("[AMIGA] Disabling PiStorm interaction device.\n");
+ }
+
+ // RTC stuff
+ if CHKVAR("rtc_type") {
+ if (val && strlen(val) != 0) {
+ if (strcmp(val, "msm") == 0) {
+ printf("[AMIGA] RTC type set to MSM.\n");
+ rtc_type = RTC_TYPE_MSM;
+ }
+ else {
+ printf("[AMIGA] RTC type set to Ricoh.\n");
+ rtc_type = RTC_TYPE_RICOH;
+ }
+ }
+ }
+}
+
+void handle_reset_amiga(struct emulator_config *cfg) {
+ ac_z2_done = (ac_z2_pic_count == 0);
+ ac_z3_done = (ac_z3_pic_count == 0);
+ ac_z2_current_pic = 0;
+ ac_z3_current_pic = 0;
+
+ DEBUG("[AMIGA] Reset handler.\n");
+ DEBUG("[AMIGA] AC done - Z2: %d Z3: %d.\n", ac_z2_done, ac_z3_done);
+
+ if (piscsi_enabled)
+ piscsi_refresh_drives();
+
+ 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");
+ }
+ }
+ if (cfg->platform->subsys) {
+ free(cfg->platform->subsys);
+ }
+ if (piscsi_enabled) {
+ piscsi_shutdown();
+ piscsi_enabled = 0;
+ }
+ if (rtg_enabled) {
+ shutdown_rtg();
+ rtg_enabled = 0;
+ }
+ if (pinet_enabled) {
+ pinet_enabled = 0;
+ }
+ if (a314_emulation_enabled) {
+ a314_emulation_enabled = 0;
+ }
+
+ cdtv_mode = 0;
+
+ autoconfig_reset_all();
+ printf("[AMIGA] Platform shutdown completed.\n");