1 #include "../platforms.h"
2 #include "amiga-autoconf.h"
7 static unsigned char ac_fast_ram_rom[] = {
8 0xe, AC_MEM_SIZE_8MB, // 00/02, link into memory free list, 8 MB
9 0x6, 0x9, // 04/06, product id
10 0x8, 0x0, // 08/0a, preference to 8 MB space
11 0x0, 0x0, // 0c/0e, reserved
12 0x0, 0x7, 0xd, 0xb, // 10/12/14/16, mfg id
13 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x2, 0x0 // 18/.../26, serial
16 static unsigned char ac_a314_rom[] = {
17 0xc, AC_MEM_SIZE_64KB, // 00/02, 64 kB
18 0xa, 0x3, // 04/06, product id
19 0x0, 0x0, // 08/0a, any space okay
20 0x0, 0x0, // 0c/0e, reserved
21 0x0, 0x7, 0xd, 0xb, // 10/12/14/16, mfg id
22 0xa, 0x3, 0x1, 0x4, 0x0, 0x0, 0x0, 0x0 // 18/.../26, serial
25 int ac_current_pic = 0;
28 int ac_type[AC_PIC_LIMIT];
29 int ac_index[AC_PIC_LIMIT];
30 unsigned int ac_base[AC_PIC_LIMIT];
32 unsigned char get_autoconf_size(int size) {
33 if (size == 8 * SIZE_MEGA)
34 return AC_MEM_SIZE_8MB;
35 if (size == 4 * SIZE_MEGA)
36 return AC_MEM_SIZE_4MB;
37 if (size == 2 * SIZE_MEGA)
38 return AC_MEM_SIZE_2MB;
40 return AC_MEM_SIZE_64KB;
43 unsigned int autoconfig_read_memory_8(struct emulator_config *cfg, unsigned int address_) {
44 unsigned char *rom = NULL;
45 int address = address_ - AC_BASE;
46 unsigned char val = 0;
48 switch(ac_type[ac_current_pic]) {
49 case ACTYPE_MAPFAST_Z2:
50 rom = ac_fast_ram_rom;
61 if ((address & 1) == 0 && (address / 2) < (int)sizeof(ac_fast_ram_rom)) {
62 if (ac_type[ac_current_pic] == ACTYPE_MAPFAST_Z2 && address / 2 == 1)
63 val = get_autoconf_size(cfg->map_size[ac_index[ac_current_pic]]);
65 val = rom[address / 2];
66 //printf("Read byte %d from autoconf for PIC %d (%.2X).\n", address/2, ac_current_pic, val);
69 if (address != 0 && address != 2 && address != 40 && address != 42)
72 return (unsigned int)val;
75 void autoconfig_write_memory_8(struct emulator_config *cfg, unsigned int address_, unsigned int value) {
76 int address = address_ - AC_BASE;
79 unsigned int *base = NULL;
81 switch(ac_type[ac_current_pic]) {
82 case ACTYPE_MAPFAST_Z2:
83 base = &ac_base[ac_current_pic];
93 printf("Failed to set up the base for autoconfig PIC %d.\n", ac_current_pic);
97 if (address == 0x4a) { // base[19:16]
98 *base = (value & 0xf0) << (16 - 4);
99 } else if (address == 0x48) { // base[23:20]
101 *base |= (value & 0xf0) << (20 - 4);
103 if (ac_type[ac_current_pic] == ACTYPE_MAPFAST_Z2) { // fast ram
104 //a314_set_mem_base_size(*base, cfg->map_size[ac_index[ac_current_pic]]);
107 } else if (address == 0x4c) { // shut up
113 //printf("Address of Z2 autoconf RAM changed to %.8x\n", ac_base[ac_current_pic]);
114 cfg->map_offset[ac_index[ac_current_pic]] = ac_base[ac_current_pic];
116 if (ac_current_pic == ac_pic_count)