Fix PiStorm dev memcpy, correct extern gayle_emulation_enabled type

This commit is contained in:
beeanyew
2021-06-04 09:37:33 +02:00
parent ceebc59532
commit 5c60601e00
6 changed files with 28 additions and 6 deletions

View File

@@ -40,7 +40,7 @@ extern int ac_z3_pic_count;
extern int ac_z3_done;
extern int ac_z3_type[AC_PIC_LIMIT];
extern int ac_z3_index[AC_PIC_LIMIT];
extern int gayle_emulation_enabled;
extern uint8_t gayle_emulation_enabled;
char *z2_autoconf_id = "z2_autoconf_fast";
char *z2_autoconf_zap_id = "^2_autoconf_fast";

View File

@@ -5,7 +5,7 @@
#include "amiga-registers.h"
uint8_t rtc_emulation_enabled = 1;
extern int gayle_emulation_enabled;
extern uint8_t gayle_emulation_enabled;
void configure_rtc_emulation_amiga(uint8_t enabled) {
if (enabled == rtc_emulation_enabled)

View File

@@ -15,6 +15,7 @@
#include <linux/reboot.h>
#include <sys/reboot.h>
#include <endian.h>
#define DEBUG_PISTORM_DEVICE
@@ -39,6 +40,7 @@ extern uint32_t do_reset;
extern void adjust_ranges_amiga(struct emulator_config *cfg);
extern uint8_t rtg_enabled, rtg_on, pinet_enabled, piscsi_enabled, load_new_config, end_signal;
extern struct emulator_config *cfg;
extern int cpu_emulation_running;
char cfg_filename[256] = "default.cfg";
char tmp_string[256];
@@ -180,6 +182,18 @@ void handle_pistorm_dev_write(uint32_t addr_, uint32_t val, uint8_t type) {
pi_string[0] = 0;
pi_ptr[0] = 0;
break;
case PI_CMD_MEMCPY_Q:
DEBUG("CopyMemQuick.\n");
if ((pi_ptr[0] & 0x03) != 0) {
DEBUG("[!!!PISTORM-DEV] CopyMemQuick src not aligned: %.8X\n", pi_ptr[0]);
}
if (pi_ptr[1] & 0x03) {
DEBUG("[!!!PISTORM-DEV] CopyMemQuick dst not aligned: %.8X\n", pi_ptr[1]);
}
if (val & 0x03) {
DEBUG("[!!!PISTORM-DEV] CopyMemQuick size not aligned: %.8X\n", val);
}
// Fallthrough
case PI_CMD_MEMCPY:
//DEBUG("[PISTORM-DEV} Write to MEMCPY: %d (%.8X)\n", val, val);
if (pi_ptr[0] == 0 || pi_ptr[1] == 0) {
@@ -189,6 +203,7 @@ void handle_pistorm_dev_write(uint32_t addr_, uint32_t val, uint8_t type) {
printf("[PISTORM-DEV] MEMCPY called with size 0. Aborting.\n");
pi_cmd_result = PI_RES_INVALIDVALUE;
} else {
//DEBUG("[PISTORM-DEV] Copy %d bytes from $%.8X to $%.8X\n", val, pi_ptr[0], pi_ptr[1]);
int32_t src = get_mapped_item_by_address(cfg, pi_ptr[0]);
int32_t dst = get_mapped_item_by_address(cfg, pi_ptr[1]);
if (cfg->map_type[dst] == MAPTYPE_ROM)
@@ -202,10 +217,10 @@ void handle_pistorm_dev_write(uint32_t addr_, uint32_t val, uint8_t type) {
uint16_t tmps = 0;
for (uint32_t i = 0; i < val; i++) {
while (i + 2 < val) {
if (src == -1) tmps = (uint16_t)m68k_read_memory_16(pi_ptr[0] + i);
if (src == -1) tmps = (uint16_t)htobe16(m68k_read_memory_16(pi_ptr[0] + i));
else memcpy(&tmps, &cfg->map_data[src][pi_ptr[0] - cfg->map_offset[src] + i], 2);
if (dst == -1) m68k_write_memory_16(pi_ptr[1] + i, tmps);
if (dst == -1) m68k_write_memory_16(pi_ptr[1] + i, be16toh(tmps));
else memcpy(&cfg->map_data[dst][pi_ptr[1] - cfg->map_offset[dst] + i], &tmps, 2);
i += 2;
}

View File

@@ -40,7 +40,7 @@ struct Screen *(*oldOpenScreen)(struct NewScreen *asm("a0"));
#define AUTO_MONITOR_ID ((options.bits.auto_mon==0)?(PAL_MONITOR_ID):((options.bits.auto_mon==1)?(NTSC_MONITOR_ID):(DEFAULT_MONITOR_ID)))
extern unsigned int pistorm_base_addr;
#define WRITELONG(cmd, val) *(unsigned int *)((unsigned int)(pistorm_base_addr+cmd)) = val;
#define WRITELONG(cmd, val) *(volatile unsigned int *)((unsigned int)(pistorm_base_addr+cmd)) = val;
void pi_CopyMem(unsigned char *src asm("a0"), unsigned char *dst asm("a1"), unsigned int size asm("d0")) {
WRITELONG(PI_PTR1, (unsigned int)src);
@@ -48,6 +48,12 @@ void pi_CopyMem(unsigned char *src asm("a0"), unsigned char *dst asm("a1"), unsi
WRITELONG(PI_CMD_MEMCPY, size);
}
void pi_CopyMemQuick(unsigned char *src asm("a0"), unsigned char *dst asm("a1"), unsigned int size asm("d0")) {
WRITELONG(PI_PTR1, (unsigned int)src);
WRITELONG(PI_PTR2, (unsigned int)dst);
WRITELONG(PI_CMD_MEMCPY_Q, size);
}
int leave(int x)
{
Forbid();
@@ -87,7 +93,8 @@ int main(int argc,char *argv[])
oldCopyMemPtr = (APTR)SetFunction((struct Library *)SysBase, -0x270, pi_CopyMem);
oldCopyMemQuickPtr = (APTR)SetFunction((struct Library *)SysBase, -0x276, pi_CopyMem);
oldCopyMemQuickPtr = (APTR)SetFunction((struct Library *)SysBase, -0x276, pi_CopyMemQuick);
//oldCopyMemQuickPtr = (APTR)SetFunction((struct Library *)SysBase, -0x276, pi_CopyMem);
do
{