mirror of
https://github.com/captain-amygdala/pistorm.git
synced 2026-01-30 21:31:55 +00:00
Add makeshift PiStorm-powered CopyMem/Quick patcher
Probably doesn't work properly with MMU libraries installed, be advised.
This commit is contained in:
@@ -197,7 +197,6 @@ void handle_pistorm_dev_write(uint32_t addr_, uint32_t val, uint8_t type) {
|
||||
uint8_t *dst_ptr = &cfg->map_data[dst][(pi_ptr[1] - cfg->map_offset[dst])];
|
||||
memcpy(dst_ptr, src_ptr, val);
|
||||
} else {
|
||||
printf("!!! doing manual memcpy\n");
|
||||
uint8_t tmp = 0;
|
||||
for (uint32_t i = 0; i < val; i++) {
|
||||
if (src == -1) tmp = (unsigned char)m68k_read_memory_8(pi_ptr[0] + i);
|
||||
|
||||
BIN
platforms/amiga/pistorm-dev/pistorm_dev_amiga/CopyMems
Normal file
BIN
platforms/amiga/pistorm-dev/pistorm_dev_amiga/CopyMems
Normal file
Binary file not shown.
@@ -1 +1,2 @@
|
||||
m68k-amigaos-gcc pistorm_dev.c simple_interact.c -mregparm -m68020 -O2 -o PiSimple -Wno-unused-parameter -noixemul -DHAS_STDLIB -Wall
|
||||
m68k-amigaos-gcc pistorm_dev.c copymems.c -m68020 -O2 -o CopyMems -Wno-unused-parameter -noixemul -DHAS_STDLIB -Wall -Wall -Wpedantic
|
||||
|
||||
99
platforms/amiga/pistorm-dev/pistorm_dev_amiga/copymems.c
Normal file
99
platforms/amiga/pistorm-dev/pistorm_dev_amiga/copymems.c
Normal file
@@ -0,0 +1,99 @@
|
||||
#include <clib/exec_protos.h>
|
||||
#include <clib/intuition_protos.h>
|
||||
#include <clib/utility_protos.h>
|
||||
#include <clib/graphics_protos.h>
|
||||
|
||||
#include <exec/types.h>
|
||||
#include <exec/resident.h>
|
||||
#include <exec/errors.h>
|
||||
#include <exec/memory.h>
|
||||
#include <exec/lists.h>
|
||||
#include <exec/alerts.h>
|
||||
#include <exec/tasks.h>
|
||||
#include <exec/io.h>
|
||||
#include <exec/execbase.h>
|
||||
|
||||
#include <intuition/intuition.h>
|
||||
#include <intuition/screens.h>
|
||||
|
||||
#include <graphics/displayinfo.h>
|
||||
#include "pistorm_dev.h"
|
||||
#include "../pistorm-dev-enums.h"
|
||||
|
||||
#include <dos/dos.h>
|
||||
#include <stdio.h>
|
||||
|
||||
struct ExecBase *SysBase;
|
||||
|
||||
char *oldtaskname;
|
||||
struct Task *task;
|
||||
|
||||
void (*oldCopyMem)(unsigned char *asm("a0"), unsigned char *asm("a1"), unsigned int asm("d0"));
|
||||
void (*oldCopyMemQuick)(unsigned char *asm("a0"), unsigned char *asm("a1"), unsigned int asm("d0"));
|
||||
APTR oldCopyMemPtr;
|
||||
APTR oldCopyMemQuickPtr;
|
||||
|
||||
struct Screen *(*oldOpenScreenTagList)(struct NewScreen *n asm("a0"), struct TagItem *asm("a1"));
|
||||
struct Screen *(*oldOpenScreen)(struct NewScreen *asm("a0"));
|
||||
|
||||
#define NORM_MONITOR_ID ((options.bits.norm_mon==1)?(PAL_MONITOR_ID):((options.bits.norm_mon==2)?(NTSC_MONITOR_ID):(DEFAULT_MONITOR_ID)))
|
||||
#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;
|
||||
|
||||
void pi_CopyMem(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, size);
|
||||
}
|
||||
|
||||
int leave(int x)
|
||||
{
|
||||
Forbid();
|
||||
task->tc_Node.ln_Name = oldtaskname;
|
||||
Permit();
|
||||
return(x);
|
||||
}
|
||||
|
||||
ULONG pistorm_addr = 0xFFFFFFFF;
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
char *task_name = "PiMems ";
|
||||
SysBase = *(struct ExecBase **)4L;
|
||||
|
||||
unsigned char no_quit = 1;
|
||||
|
||||
task = (struct Task *)FindTask((STRPTR)&task_name);
|
||||
|
||||
if(task)
|
||||
return(0);
|
||||
|
||||
task = (struct Task *)FindTask(NULL);
|
||||
oldtaskname = task->tc_Node.ln_Name;
|
||||
|
||||
Forbid();
|
||||
task->tc_Node.ln_Name = (char *)&task_name;
|
||||
Permit();
|
||||
|
||||
pistorm_addr = pi_find_pistorm();
|
||||
if (pistorm_addr == 0xFFFFFFFF) {
|
||||
printf("We dead!\n");
|
||||
return(leave(50));
|
||||
} else {
|
||||
pistorm_base_addr = pistorm_addr;
|
||||
}
|
||||
|
||||
oldCopyMemPtr = (APTR)SetFunction((struct Library *)SysBase, -0x270, pi_CopyMem);
|
||||
|
||||
oldCopyMemQuickPtr = (APTR)SetFunction((struct Library *)SysBase, -0x276, pi_CopyMem);
|
||||
|
||||
do
|
||||
{
|
||||
Wait(SIGBREAKF_CTRL_C);
|
||||
}
|
||||
while(no_quit);
|
||||
|
||||
return(leave(0));
|
||||
}
|
||||
Reference in New Issue
Block a user