1 #include "../platforms.h"
2 #include "amiga-autoconf.h"
7 int handle_register_read_amiga(unsigned int addr, unsigned char type, unsigned int *val);
8 int handle_register_write_amiga(unsigned int addr, unsigned int value, unsigned char type);
11 extern int ac_pic_count;
12 extern int ac_type[AC_PIC_LIMIT];
13 extern int ac_index[AC_PIC_LIMIT];
15 const char *z2_autoconf_id = "z2_autoconf_fast";
16 const char *z2_autoconf_zap_id = "^2_autoconf_fast";
18 int custom_read_amiga(struct emulator_config *cfg, unsigned int addr, unsigned int *val, unsigned char type) {
19 if (!ac_done && addr >= AC_BASE && addr < AC_BASE + AC_SIZE) {
20 if (ac_pic_count == 0) {
25 if (type == OP_TYPE_BYTE) {
26 //printf("Read from autoconf area.\n");
27 *val = autoconfig_read_memory_8(cfg, addr);
35 int custom_write_amiga(struct emulator_config *cfg, unsigned int addr, unsigned int val, unsigned char type) {
36 if (cfg || addr || val || type) {}
37 if (!ac_done && addr >= AC_BASE && addr < AC_BASE + AC_SIZE) {
38 if (type == OP_TYPE_BYTE) {
39 if (ac_pic_count == 0) {
44 //printf("Write to autoconf area.\n");
45 autoconfig_write_memory_8(cfg, addr, val);
53 int setup_platform_amiga(struct emulator_config *cfg) {
55 printf("Performing setup for Amiga platform.\n");
56 // Look for Z2 autoconf Fast RAM by id
57 int index = get_named_mapped_item(cfg, "z2_autoconf_fast");
60 cfg->map_id[index][0] = '^';
62 if (cfg->map_size[index] > 8 * SIZE_MEGA) {
63 printf("Attempted to configure more than 8MB of Z2 Fast RAM, downsizng to 8MB.\n");
64 resize_data = 8 * SIZE_MEGA;
66 else if(cfg->map_size[index] != 2 * SIZE_MEGA && cfg->map_size[index] != 4 * SIZE_MEGA && cfg->map_size[index] != 8 * SIZE_MEGA) {
67 printf("Z2 Fast RAM may only provision 2, 4 or 8MB of memory, resizing to ");
68 if (cfg->map_size[index] > 8 * SIZE_MEGA)
69 resize_data = 8 * SIZE_MEGA;
70 else if (cfg->map_size[index] > 4 * SIZE_MEGA)
71 resize_data = 4 * SIZE_MEGA;
73 resize_data = 2 * SIZE_MEGA;
74 printf("%dMB.\n", resize_data / SIZE_MEGA);
77 free(cfg->map_data[index]);
78 cfg->map_size[index] = resize_data;
79 cfg->map_data[index] = (unsigned char *)malloc(cfg->map_size[index]);
81 printf("%dMB of Z2 Fast RAM configured at $%lx\n", cfg->map_size[index] / SIZE_MEGA, cfg->map_offset[index]);
82 ac_type[ac_pic_count] = ACTYPE_MAPFAST_Z2;
83 ac_index[ac_pic_count] = index;
88 printf("No Z2 Fast RAM configured.\n");
89 index = get_named_mapped_item(cfg, "z2_autoconf_fast");
93 for (int i = 0; i < MAX_NUM_MAPPED_ITEMS; i ++) {
94 if (cfg->map_id[i] && strcmp(cfg->map_id[i], z2_autoconf_zap_id) == 0) {
95 cfg->map_id[i][0] = 'z';
102 void setvar_amiga(char *var, char *val) {
106 void create_platform_amiga(struct platform_config *cfg, char *subsys) {
107 cfg->register_read = handle_register_read_amiga;
108 cfg->register_write = handle_register_write_amiga;
109 cfg->custom_read = custom_read_amiga;
110 cfg->custom_write = custom_write_amiga;
111 cfg->platform_initial_setup = setup_platform_amiga;
113 cfg->setvar = setvar_amiga;
116 cfg->subsys = malloc(strlen(subsys) + 1);
117 strcpy(cfg->subsys, subsys);