void m68k_write_memory_16(unsigned int address, unsigned int value);
void m68k_write_memory_32(unsigned int address, unsigned int value);
+/* PiStorm speed hax */
+void m68k_add_ram_range(uint32_t addr, uint32_t upper, unsigned char *ptr);
+void m68k_add_rom_range(uint32_t addr, uint32_t upper, unsigned char *ptr);
+
/* Special call to simulate undocumented 68k behavior when move.l with a
* predecrement destination mode is executed.
* To simulate real 68k behavior, first write the high word to
extern void (*m68ki_instruction_jump_table[0x10000])(void); /* opcode handler jump table */
extern void m68ki_build_opcode_table(void);
+static unsigned char read_ranges;
+static unsigned int read_addr[8];
+static unsigned int read_upper[8];
+static unsigned char *read_data[8];
+static unsigned char write_ranges;
+static unsigned int write_addr[8];
+static unsigned int write_upper[8];
+static unsigned char *write_data[8];
+
#include "m68kops.h"
#include "m68kcpu.h"
if(src) m68ki_cpu = *(m68ki_cpu_core*)src;
}
+void m68k_add_ram_range(uint32_t addr, uint32_t upper, unsigned char *ptr)
+{
+ if (read_ranges + 1 < 8) {
+ read_addr[read_ranges] = addr;
+ read_upper[read_ranges] = upper;
+ read_data[read_ranges] = ptr;
+ read_ranges++;
+ printf("[MUSASHI] Mapped read range %d: %.8X-%.8X (%p)\n", read_ranges, addr, upper, ptr);
+ }
+ else {
+ printf("Can't Musashi map more than eight RAM/ROM read ranges.\n");
+ }
+ if (write_ranges + 1 < 8) {
+ write_addr[write_ranges] = addr;
+ write_upper[write_ranges] = upper;
+ write_data[write_ranges] = ptr;
+ write_ranges++;
+ printf("[MUSASHI] Mapped write range %d: %.8X-%.8X (%p)\n", write_ranges, addr, upper, ptr);
+ }
+ else {
+ printf("Can't Musashi map more than eight RAM write ranges.\n");
+ }
+}
+
+void m68k_add_rom_range(uint32_t addr, uint32_t upper, unsigned char *ptr)
+{
+ if (read_ranges + 1 < 8) {
+ read_addr[read_ranges] = addr;
+ read_upper[read_ranges] = upper;
+ read_data[read_ranges] = ptr;
+ read_ranges++;
+ printf("[MUSASHI] Mapped read range %d: %.8X-%.8X (%p)\n", read_ranges, addr, upper, ptr);
+ }
+ else {
+ printf("Can't Musashi map more than eight RAM/ROM read ranges.\n");
+ }
+}
+
/* ======================================================================== */
/* ============================== MAME STUFF ============================== */
/* ======================================================================== */
#include "m68k.h"
#include <limits.h>
+#include <endian.h>
#include <setjmp.h>
* These functions will also check for address error and set the function
* code if they are enabled in m68kconf.h.
*/
+
+static unsigned char read_ranges;
+static unsigned int read_addr[8];
+static unsigned int read_upper[8];
+static unsigned char *read_data[8];
+static unsigned char write_ranges;
+static unsigned int write_addr[8];
+static unsigned int write_upper[8];
+static unsigned char *write_data[8];
+
static inline uint m68ki_read_8_fc(uint address, uint fc)
{
(void)fc;
address = pmmu_translate_addr(address);
#endif
+ for (int i = 0; i < read_ranges; i++) {
+ if(address >= read_addr[i] && address < read_upper[i]) {
+ return read_data[i][address];
+ }
+ }
+
return m68k_read_memory_8(ADDRESS_68K(address));
}
static inline uint m68ki_read_16_fc(uint address, uint fc)
address = pmmu_translate_addr(address);
#endif
+ for (int i = 0; i < read_ranges; i++) {
+ if(address >= read_addr[i] && address < read_upper[i]) {
+ return be16toh(((unsigned short *)(read_data[i] + (address - read_addr[i])))[0]);
+ }
+ }
+
return m68k_read_memory_16(ADDRESS_68K(address));
}
static inline uint m68ki_read_32_fc(uint address, uint fc)
address = pmmu_translate_addr(address);
#endif
+ for (int i = 0; i < read_ranges; i++) {
+ if(address >= read_addr[i] && address < read_upper[i]) {
+ return be32toh(((unsigned int *)(read_data[i] + (address - read_addr[i])))[0]);
+ }
+ }
+
return m68k_read_memory_32(ADDRESS_68K(address));
}
address = pmmu_translate_addr(address);
#endif
+ for (int i = 0; i < write_ranges; i++) {
+ if(address >= write_addr[i] && address < write_upper[i]) {
+ write_data[i][address] = (unsigned char)value;
+ return;
+ }
+ }
+
m68k_write_memory_8(ADDRESS_68K(address), value);
}
static inline void m68ki_write_16_fc(uint address, uint fc, uint value)
address = pmmu_translate_addr(address);
#endif
+ for (int i = 0; i < write_ranges; i++) {
+ if(address >= write_addr[i] && address < write_upper[i]) {
+ ((short *)(read_data[i] + (address - read_addr[i])))[0] = htobe16(value);
+ return;
+ }
+ }
+
m68k_write_memory_16(ADDRESS_68K(address), value);
}
static inline void m68ki_write_32_fc(uint address, uint fc, uint value)
address = pmmu_translate_addr(address);
#endif
+ for (int i = 0; i < write_ranges; i++) {
+ if(address >= write_addr[i] && address < write_upper[i]) {
+ ((int *)(read_data[i] + (address - read_addr[i])))[0] = htobe32(value);
+ return;
+ }
+ }
+
m68k_write_memory_32(ADDRESS_68K(address), value);
}
if (done) {
nib_latch = 0;
- printf("Address of Z3 autoconf RAM assigned to $%.8x\n", ac_base[ac_z3_current_pic]);
+ printf("Address of Z3 autoconf RAM assigned to $%.8x [B]\n", ac_base[ac_z3_current_pic]);
cfg->map_offset[index] = ac_base[ac_z3_current_pic];
cfg->map_high[index] = cfg->map_offset[index] + cfg->map_size[index];
+ m68k_add_ram_range(cfg->map_offset[index], cfg->map_high[index], cfg->map_data[index]);
ac_z3_current_pic++;
if (ac_z3_current_pic == ac_z3_pic_count) {
ac_z3_done = 1;
switch(address & 0xFF) {
case AC_Z3_REG_WR_ADDR_HI:
- // This is, as far as I know, the only regiter it should write a 16-bit value to.
+ // This is, as far as I know, the only register it should write a 16-bit value to.
ac_base[ac_z3_current_pic] = (ac_base[ac_z3_current_pic] & 0x00000000) | (val << 16);
done = 1;
break;
}
if (done) {
- printf("Address of Z3 autoconf RAM assigned to $%.8x\n", ac_base[ac_z3_current_pic]);
+ printf("Address of Z3 autoconf RAM assigned to $%.8x [W]\n", ac_base[ac_z3_current_pic]);
cfg->map_offset[index] = ac_base[ac_z3_current_pic];
+ cfg->map_high[index] = cfg->map_offset[index] + cfg->map_size[index];
+ m68k_add_ram_range(cfg->map_offset[index], cfg->map_high[index], cfg->map_data[index]);
ac_z3_current_pic++;
if (ac_z3_current_pic == ac_z3_pic_count)
ac_z3_done = 1;
printf("Address of Z2 autoconf RAM assigned to $%.8x\n", ac_base[ac_z2_current_pic]);
cfg->map_offset[index] = ac_base[ac_z2_current_pic];
cfg->map_high[index] = cfg->map_offset[index] + cfg->map_size[index];
+ m68k_add_ram_range(cfg->map_offset[index], cfg->map_high[index], cfg->map_data[index]);
printf("Z2 PIC %d at $%.8lX-%.8lX, Size: %d MB\n", ac_z2_current_pic, cfg->map_offset[index], cfg->map_high[index], cfg->map_size[index] / SIZE_MEGA);
ac_z2_current_pic++;
if (ac_z2_current_pic == ac_z2_pic_count) {
}
int setup_platform_amiga(struct emulator_config *cfg) {
- if (cfg) {}
printf("Performing setup for Amiga platform.\n");
// Look for Z2 autoconf Fast RAM by id
int index = get_named_mapped_item(cfg, z2_autoconf_id);
}
}
+ index = get_named_mapped_item(cfg, "cpu_slot_ram");
+ if (index != -1) {
+ m68k_add_ram_range((uint32_t)cfg->map_offset[index], (uint32_t)cfg->map_high[index], cfg->map_data[index]);
+ }
+
adjust_ranges_amiga(cfg);
return 0;