sim65 common define for paravirt hooks base location

allows the loaded binary to take up as much space as possible
restored some documentation of the hooks but without reference to specific location
This commit is contained in:
bbbradsmith
2019-05-30 15:34:05 -04:00
committed by Oliver Schmidt
parent 6efb71bea7
commit 5269552346
4 changed files with 26 additions and 20 deletions

View File

@@ -200,8 +200,8 @@ static unsigned char ReadProgramFile (void)
/* Read the file body into memory */
Addr = Load;
while ((Val = fgetc(F)) != EOF) {
if (Addr == 0xFF00) {
Error ("'%s': To large to fit into $%04X-$FFF0", ProgramFile, Addr);
if (Addr >= PARAVIRT_BASE) {
Error ("'%s': To large to fit into $%04X-$%04X", ProgramFile, Addr, PARAVIRT_BASE);
}
MemWriteByte (Addr++, (unsigned char) Val);
}

View File

@@ -318,13 +318,13 @@ void ParaVirtHooks (CPURegs* Regs)
/* Potentially execute paravirtualization hooks */
{
/* Check for paravirtualization address range */
if (Regs->PC < 0xFFF4 ||
Regs->PC >= 0xFFF4 + sizeof (Hooks) / sizeof (Hooks[0])) {
if (Regs->PC < PARAVIRT_BASE ||
Regs->PC >= PARAVIRT_BASE + sizeof (Hooks) / sizeof (Hooks[0])) {
return;
}
/* Call paravirtualization hook */
Hooks[Regs->PC - 0xFFF4] (Regs);
Hooks[Regs->PC - PARAVIRT_BASE] (Regs);
/* Simulate RTS */
Regs->PC = Pop(Regs) + (Pop(Regs) << 8) + 1;

View File

@@ -38,6 +38,17 @@
/*****************************************************************************/
/* Data */
/*****************************************************************************/
#define PARAVIRT_BASE 0xFFF4
/* Lowest address used by a paravirtualization hook */
/*****************************************************************************/
/* Code */
/*****************************************************************************/