extern const char *op_type_names[OP_TYPE_NUM];
+#define min(a, b) (a < b) ? a : b
+#define max(a, b) (a > b) ? a : b
+
inline int custom_read_amiga(struct emulator_config *cfg, unsigned int addr, unsigned int *val, unsigned char type) {
if (!ac_z2_done && addr >= AC_Z2_BASE && addr < AC_Z2_BASE + AC_SIZE) {
if (ac_z2_pic_count == 0) {
return -1;
}
- printf("Write to Z2 autoconf area.\n");
+ //printf("Write to Z2 autoconf area.\n");
autoconfig_write_memory_8(cfg, addr, val);
return 1;
}
return -1;
}
+void adjust_ranges_amiga(struct emulator_config *cfg) {
+ cfg->mapped_high = 0;
+ cfg->mapped_low = 0;
+ cfg->custom_high = 0;
+ cfg->custom_low = 0;
+
+ // Set up the min/max ranges for mapped reads/writes
+ if (gayle_emulation_enabled) {
+ cfg->mapped_low = GAYLEBASE;
+ cfg->mapped_high = GAYLEBASE + GAYLESIZE;
+ }
+ for (int i = 0; i < MAX_NUM_MAPPED_ITEMS; i++) {
+ if (cfg->map_type[i] != MAPTYPE_NONE) {
+ if ((cfg->map_offset[i] != 0 && cfg->map_offset[i] < cfg->mapped_low) || cfg->mapped_low == 0)
+ cfg->mapped_low = cfg->map_offset[i];
+ if (cfg->map_offset[i] + cfg->map_size[i] > cfg->mapped_high)
+ cfg->mapped_high = cfg->map_offset[i] + cfg->map_size[i];
+ }
+ }
+
+ if (ac_z2_pic_count && !ac_z2_done) {
+ if (cfg->custom_low == 0)
+ cfg->custom_low = AC_Z2_BASE;
+ else
+ cfg->custom_low = min(cfg->custom_low, AC_Z2_BASE);
+ cfg->custom_high = max(cfg->custom_high, AC_Z2_BASE + AC_SIZE);
+ }
+ if (ac_z3_pic_count && !ac_z3_done) {
+ if (cfg->custom_low == 0)
+ cfg->custom_low = AC_Z3_BASE;
+ else
+ cfg->custom_low = min(cfg->custom_low, AC_Z3_BASE);
+ cfg->custom_high = max(cfg->custom_high, AC_Z3_BASE + AC_SIZE);
+ }
+
+ printf("Platform custom range: %.8X-%.8X\n", cfg->custom_low, cfg->custom_high);
+ printf("Platform mapped range: %.8X-%.8X\n", cfg->mapped_low, cfg->mapped_high);
+}
+
int setup_platform_amiga(struct emulator_config *cfg) {
if (cfg) {}
printf("Performing setup for Amiga platform.\n");
}
}
- // Set up the min/max ranges for mapped reads/writes
- for (int i = 0; i < MAX_NUM_MAPPED_ITEMS; i++) {
- if (cfg->map_type[i] != MAPTYPE_NONE) {
- if ((cfg->map_offset[i] != 0 && cfg->map_offset[i] < cfg->map_low) || cfg->map_low == 0)
- cfg->map_low = cfg->map_offset[i];
- if (cfg->map_offset[i] + cfg->map_size[i] > cfg->map_high)
- cfg->map_high = cfg->map_offset[i] + cfg->map_size[i];
- }
- }
-
- if (gayle_emulation_enabled) {
- cfg->custom_low = GAYLEBASE;
- cfg->custom_high = GAYLEBASE + GAYLESIZE;
- }
-
- printf("Platform custom range: %.8X-%.8X\n", cfg->custom_low, cfg->custom_high);
- printf("Platform mapped range: %.8X-%.8X\n", cfg->map_low, cfg->map_high);
+ adjust_ranges_amiga(cfg);
return 0;
}
}
}
+void handle_reset_amiga(struct emulator_config *cfg) {
+ ac_z3_done = 0;
+ ac_z2_done = 0;
+
+ adjust_ranges_amiga(cfg);
+}
+
void create_platform_amiga(struct platform_config *cfg, char *subsys) {
cfg->register_read = handle_register_read_amiga;
cfg->register_write = handle_register_write_amiga;
cfg->custom_read = custom_read_amiga;
cfg->custom_write = custom_write_amiga;
cfg->platform_initial_setup = setup_platform_amiga;
+ cfg->handle_reset = handle_reset_amiga;
cfg->setvar = setvar_amiga;
cfg->id = PLATFORM_AMIGA;