mirror of
https://github.com/LIV2/pistorm.git
synced 2025-12-05 22:52:44 +00:00
Add some more Mac68k handling stuff
This commit is contained in:
parent
d485267523
commit
16a902fad2
1
Makefile
1
Makefile
@ -10,6 +10,7 @@ MAINFILES = emulator.c \
|
||||
platforms/amiga/amiga-autoconf.c \
|
||||
platforms/amiga/amiga-platform.c \
|
||||
platforms/amiga/amiga-registers.c \
|
||||
platforms/mac68k/mac68k-platform.c \
|
||||
platforms/dummy/dummy-platform.c \
|
||||
platforms/dummy/dummy-registers.c \
|
||||
platforms/amiga/Gayle.c \
|
||||
|
||||
@ -629,14 +629,11 @@ switch_config:
|
||||
void cpu_pulse_reset(void) {
|
||||
m68ki_cpu_core *state = &m68ki_cpu;
|
||||
ps_pulse_reset();
|
||||
|
||||
ovl = 1;
|
||||
if (cfg->platform->handle_reset)
|
||||
cfg->platform->handle_reset(cfg);
|
||||
|
||||
//m68k_write_memory_16(INTENA, 0x7FFF);
|
||||
ovl = 1;
|
||||
//m68k_write_memory_8(0xbfe201, 0x0001); // AMIGA OVL
|
||||
//m68k_write_memory_8(0xbfe001, 0x0001); // AMIGA OVL high (ROM@0x0)
|
||||
|
||||
m68k_pulse_reset(state);
|
||||
}
|
||||
|
||||
@ -954,9 +951,11 @@ static inline int32_t platform_write_check(uint8_t type, uint32_t addr, uint32_t
|
||||
if (val & 0x10 && !ovl) {
|
||||
ovl = 1;
|
||||
printf("[MAC] OVL on.\n");
|
||||
handle_ovl_mappings_mac68k(cfg);
|
||||
} else if (ovl) {
|
||||
ovl = 0;
|
||||
printf("[MAC] OVL off.\n");
|
||||
handle_ovl_mappings_mac68k(cfg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
1
m68k.h
1
m68k.h
@ -212,6 +212,7 @@ 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);
|
||||
void m68k_remove_range(unsigned char *ptr);
|
||||
void m68k_clear_ranges();
|
||||
|
||||
/* Special call to simulate undocumented 68k behavior when move.l with a
|
||||
|
||||
34
m68kcpu.c
34
m68kcpu.c
@ -1316,8 +1316,12 @@ void m68k_add_ram_range(uint32_t addr, uint32_t upper, unsigned char *ptr)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < m68ki_cpu.write_ranges; i++) {
|
||||
if (m68ki_cpu.write_addr[i] == addr) {
|
||||
if (m68ki_cpu.write_addr[i] == addr || m68ki_cpu.write_data[i] == ptr) {
|
||||
uint8_t changed = 0;
|
||||
if (m68ki_cpu.write_addr[i] != addr) {
|
||||
m68ki_cpu.write_addr[i] = addr;
|
||||
changed = 1;
|
||||
}
|
||||
if (m68ki_cpu.write_upper[i] != upper) {
|
||||
m68ki_cpu.write_upper[i] = upper;
|
||||
changed = 1;
|
||||
@ -1363,8 +1367,12 @@ void m68k_add_rom_range(uint32_t addr, uint32_t upper, unsigned char *ptr)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < m68ki_cpu.read_ranges; i++) {
|
||||
if (m68ki_cpu.read_addr[i] == addr) {
|
||||
if (m68ki_cpu.read_addr[i] == addr || m68ki_cpu.read_data[i] == ptr) {
|
||||
uint8_t changed = 0;
|
||||
if (m68ki_cpu.read_addr[i] != addr) {
|
||||
m68ki_cpu.read_addr[i] = addr;
|
||||
changed = 1;
|
||||
}
|
||||
if (m68ki_cpu.read_upper[i] != upper) {
|
||||
m68ki_cpu.read_upper[i] = upper;
|
||||
changed = 1;
|
||||
@ -1392,6 +1400,28 @@ void m68k_add_rom_range(uint32_t addr, uint32_t upper, unsigned char *ptr)
|
||||
}
|
||||
}
|
||||
|
||||
void m68k_remove_range(unsigned char *ptr) {
|
||||
if (!ptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
// FIXME: Replace the 8 with a #define, such as MAX_MUSASHI_RANGES
|
||||
for (int i = 0; i < 8; i++) {
|
||||
if (m68ki_cpu.read_data[i] == ptr) {
|
||||
m68ki_cpu.read_data[i] = NULL;
|
||||
m68ki_cpu.read_addr[i] = 0;
|
||||
m68ki_cpu.read_upper[i] = 0;
|
||||
printf("[MUSASHI] Unmapped read range %d.\n", i);
|
||||
}
|
||||
if (m68ki_cpu.write_data[i] == ptr) {
|
||||
m68ki_cpu.write_data[i] = NULL;
|
||||
m68ki_cpu.write_addr[i] = 0;
|
||||
m68ki_cpu.write_upper[i] = 0;
|
||||
printf("[MUSASHI] Unmapped write range %d.\n", i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void m68k_clear_ranges()
|
||||
{
|
||||
printf("[MUSASHI] Clearing all reads/write memory ranges.\n");
|
||||
|
||||
@ -356,6 +356,9 @@ uint16 pmmu_match_tt(m68ki_cpu_core *state, uint32 addr_in, int fc, uint32 tt, u
|
||||
|
||||
void update_descriptor(m68ki_cpu_core *state, uint32 tptr, int type, uint32 entry, int16 rw)
|
||||
{
|
||||
// FIXME: Silence unused variable warning
|
||||
if (state) {}
|
||||
|
||||
if (type == M68K_MMU_DF_DT_PAGE && !rw &&
|
||||
!(entry & M68K_MMU_DF_MODIFIED) &&
|
||||
!(entry & M68K_MMU_DF_WP))
|
||||
|
||||
@ -3,8 +3,9 @@
|
||||
cpu 68EC020
|
||||
|
||||
# Map any size ROM to a the (max) 512KB KB system ROM default address with OVL enabled.
|
||||
# The id=sysrom and id=sysram for the ROM and WTC RAM are necessary in order for the 68k Mac's OVL to function properly.
|
||||
# (From what I could tell, the ROM was mirrored across this entire 512KB space regardless of physical capacity.)
|
||||
map type=rom address=0x400000 size=512K file=system.rom ovl=0 id=sysrom
|
||||
map type=rom address=0x400000 size=512K file=system.rom id=sysrom
|
||||
|
||||
# Map X KB/MB of RAM starting at $0. The type of this RAM map is "wtcram", which is short for Write Through Cache RAM.
|
||||
# It appears that the Mac Classic sound/video chips can't write to RAM, only read from it, so this should be sufficient
|
||||
|
||||
156
platforms/mac68k/mac68k-platform.c
Normal file
156
platforms/mac68k/mac68k-platform.c
Normal file
@ -0,0 +1,156 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "platforms/platforms.h"
|
||||
#include "platforms/shared/rtc.h"
|
||||
|
||||
//#define DEBUG_MAC_PLATFORM
|
||||
|
||||
#ifdef DEBUG_MAC_PLATFORM
|
||||
#define DEBUG printf
|
||||
#else
|
||||
#define DEBUG(...)
|
||||
#endif
|
||||
|
||||
#define min(a, b) (a < b) ? a : b
|
||||
#define max(a, b) (a > b) ? a : b
|
||||
|
||||
extern void stop_cpu_emulation(uint8_t disasm_cur);
|
||||
|
||||
uint8_t iscsi_enabled;
|
||||
|
||||
extern int kb_hook_enabled;
|
||||
extern int mouse_hook_enabled;
|
||||
extern unsigned int ovl;
|
||||
|
||||
void adjust_ranges_mac68k(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
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
printf("[MAC68K] Platform custom range: %.8X-%.8X\n", cfg->custom_low, cfg->custom_high);
|
||||
printf("[MAC68K] Platform mapped range: %.8X-%.8X\n", cfg->mapped_low, cfg->mapped_high);
|
||||
}
|
||||
|
||||
|
||||
int setup_platform_mac68k(struct emulator_config *cfg) {
|
||||
printf("Performing setup for Mac68k platform.\n");
|
||||
|
||||
if (strlen(cfg->platform->subsys)) {
|
||||
printf("Sub system %sd specified, but no handler is available for this.\n", cfg->platform->subsys);
|
||||
}
|
||||
else
|
||||
printf("No sub system specified.\n");
|
||||
|
||||
handle_ovl_mappings_mac68k(cfg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define CHKVAR(a) (strcmp(var, a) == 0)
|
||||
|
||||
void setvar_mac68k(struct emulator_config *cfg, char *var, char *val) {
|
||||
if (!var)
|
||||
return;
|
||||
|
||||
// FIXME: Silence unused variable warnings.
|
||||
if (var || cfg || val) {}
|
||||
|
||||
if (CHKVAR("iscsi") && !iscsi_enabled) {
|
||||
printf("[MAC68K] iSCSI Interface Enabled... well, not really.\n");
|
||||
iscsi_enabled = 1;
|
||||
//iscsi_init();
|
||||
//adjust_ranges_mac68k(cfg);
|
||||
}
|
||||
}
|
||||
|
||||
void handle_ovl_mappings_mac68k(struct emulator_config *cfg) {
|
||||
int32_t index = -1;
|
||||
|
||||
index = get_named_mapped_item(cfg, "sysrom");
|
||||
if (index != -1) {
|
||||
cfg->map_offset[index] = (ovl) ? 0x0 : 0x400000;
|
||||
cfg->map_high[index] = cfg->map_size[index];
|
||||
m68k_remove_range(cfg->map_data[index]);
|
||||
m68k_add_rom_range((uint32_t)cfg->map_offset[index], (uint32_t)cfg->map_high[index], cfg->map_data[index]);
|
||||
printf("[MAC68K] Added memory mapping for Mac68k System ROM.\n");
|
||||
} else {
|
||||
printf ("[MAC68K] No sysrom mapping found. If you intended to memory map a system ROM, make sure it has the correct ID.\n");
|
||||
}
|
||||
index = get_named_mapped_item(cfg, "sysram");
|
||||
if (index != -1) {
|
||||
cfg->map_offset[index] = (ovl) ? 0x400000 : 0x0;
|
||||
cfg->map_high[index] = cfg->map_size[index];
|
||||
m68k_remove_range(cfg->map_data[index]);
|
||||
m68k_add_ram_range((uint32_t)cfg->map_offset[index], (uint32_t)cfg->map_high[index], cfg->map_data[index]);
|
||||
printf("[MAC68K] Added memory mapping for Mac68k System RAM.\n");
|
||||
} else {
|
||||
printf ("[MAC68K] No sysram mapping found. If you intended to memory map a system RAM, make sure it has the correct ID.\n");
|
||||
}
|
||||
|
||||
adjust_ranges_mac68k(cfg);
|
||||
}
|
||||
|
||||
void handle_reset_mac68k(struct emulator_config *cfg) {
|
||||
DEBUG("[MAC68K] Reset handler.\n");
|
||||
|
||||
if (iscsi_enabled) {
|
||||
//iscsi_refresh_drives();
|
||||
}
|
||||
|
||||
handle_ovl_mappings_mac68k(cfg);
|
||||
}
|
||||
|
||||
void shutdown_platform_mac68k(struct emulator_config *cfg) {
|
||||
printf("[MAC68K] Performing Mac68k platform shutdown.\n");
|
||||
if (cfg) {}
|
||||
|
||||
if (cfg->platform->subsys) {
|
||||
free(cfg->platform->subsys);
|
||||
cfg->platform->subsys = NULL;
|
||||
}
|
||||
if (iscsi_enabled) {
|
||||
//iscsi_shutdown();
|
||||
iscsi_enabled = 0;
|
||||
}
|
||||
|
||||
mouse_hook_enabled = 0;
|
||||
kb_hook_enabled = 0;
|
||||
|
||||
printf("[MAC68K] Platform shutdown completed.\n");
|
||||
}
|
||||
|
||||
void create_platform_mac68k(struct platform_config *cfg, char *subsys) {
|
||||
cfg->register_read = NULL;
|
||||
cfg->register_write = NULL;
|
||||
cfg->custom_read = NULL;
|
||||
cfg->custom_write = NULL;
|
||||
cfg->platform_initial_setup = setup_platform_mac68k;
|
||||
cfg->handle_reset = handle_reset_mac68k;
|
||||
cfg->shutdown = shutdown_platform_mac68k;
|
||||
|
||||
cfg->setvar = setvar_mac68k;
|
||||
cfg->id = PLATFORM_MAC;
|
||||
|
||||
if (subsys) {
|
||||
cfg->subsys = malloc(strlen(subsys) + 1);
|
||||
strcpy(cfg->subsys, subsys);
|
||||
for (unsigned int i = 0; i < strlen(cfg->subsys); i++) {
|
||||
cfg->subsys[i] = tolower(cfg->subsys[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -24,6 +24,7 @@ int get_platform_index(char *name) {
|
||||
}
|
||||
|
||||
void create_platform_amiga(struct platform_config *cfg, char *subsys);
|
||||
void create_platform_mac68k(struct platform_config *cfg, char *subsys);
|
||||
void create_platform_dummy(struct platform_config *cfg, char *subsys);
|
||||
|
||||
struct platform_config *make_platform_config(char *name, char *subsys) {
|
||||
@ -50,8 +51,10 @@ struct platform_config *make_platform_config(char *name, char *subsys) {
|
||||
case PLATFORM_AMIGA:
|
||||
create_platform_amiga(cfg, subsys);
|
||||
break;
|
||||
case PLATFORM_NONE:
|
||||
case PLATFORM_MAC:
|
||||
create_platform_mac68k(cfg, subsys);
|
||||
break;
|
||||
case PLATFORM_NONE:
|
||||
case PLATFORM_X68000:
|
||||
default:
|
||||
create_platform_dummy(cfg, subsys);
|
||||
|
||||
@ -14,3 +14,5 @@ struct platform_config *make_platform_config(char *name, char *subsys);
|
||||
|
||||
void dump_range_to_file(uint32_t addr, uint32_t size, char *filename);
|
||||
uint8_t *dump_range_to_memory(uint32_t addr, uint32_t size);
|
||||
|
||||
void handle_ovl_mappings_mac68k(struct emulator_config *cfg);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user