/** * Copy ST GEMDOS intercept program image into cartridge memory space * or load an external cartridge file. * The intercept program is part of Hatari and used as an interface to the host * file system through GemDOS. It is also needed for Line-A-Init when using * extended VDI resolutions. */ void Cart_ResetImage(void) { int PatchIllegal = FALSE; /* "Clear" cartridge ROM space */ memset(&RomMem[0xfa0000], 0xff, 0x20000); /* Print a warning if user tries to use an external cartridge file * together with GEMDOS HD emulation or extended VDI resolution: */ if (strlen(ConfigureParams.Rom.szCartridgeImageFileName) > 0) { if (bUseVDIRes) Log_Printf(LOG_WARN, "Cartridge can't be used together with extended VDI resolution!\n"); if (ConfigureParams.HardDisk.bUseHardDiskDirectories) Log_Printf(LOG_WARN, "Cartridge can't be used together with GEMDOS hard disk emulation!\n"); } /* Use internal cartridge when user wants extended VDI resolution or GEMDOS HD. */ if (bUseVDIRes || ConfigureParams.HardDisk.bUseHardDiskDirectories) { /* Copy built-in cartrige data into the cartridge memory of the ST */ memcpy(&RomMem[0xfa0000], Cart_data, sizeof(Cart_data)); PatchIllegal = TRUE; } else if (strlen(ConfigureParams.Rom.szCartridgeImageFileName) > 0) { /* Load external image file: */ Cart_LoadImage(); } if (PatchIllegal == TRUE) { //fprintf ( stderr ," Cart_ResetImage patch\n" ); /* Hatari's specific illegal opcodes for HD emulation */ cpufunctbl[GEMDOS_OPCODE] = OpCode_GemDos; /* 0x0008 */ cpufunctbl[SYSINIT_OPCODE] = OpCode_SysInit; /* 0x000a */ cpufunctbl[VDI_OPCODE] = OpCode_VDI; /* 0x000c */ } else { //fprintf ( stderr ," Cart_ResetImage no patch\n" ); /* No built-in cartridge loaded : set same handler as 0x4afc (illegal) */ cpufunctbl[GEMDOS_OPCODE] = cpufunctbl[ 0x4afc ]; /* 0x0008 */ cpufunctbl[SYSINIT_OPCODE] = cpufunctbl[ 0x4afc ]; /* 0x000a */ cpufunctbl[VDI_OPCODE] = cpufunctbl[ 0x4afc ]; /* 0x000c */ } }
/** * Copy ST GEMDOS intercept program image into cartridge memory space * or load an external cartridge file. * The intercept program is part of Hatari and used as an interface to the host * file system through GemDOS. It is also needed for Line-A-Init when using * extended VDI resolutions. */ void Cart_ResetImage(void) { int PatchIllegal = false; /* "Clear" cartridge ROM space */ memset(&RomMem[0xfa0000], 0xff, 0x20000); /* Print a warning if user tries to use an external cartridge file * together with GEMDOS HD emulation or extended VDI resolution: */ if (strlen(ConfigureParams.Rom.szCartridgeImageFileName) > 0) { if (bUseVDIRes) Log_Printf(LOG_WARN, "Cartridge can't be used together with extended VDI resolution!\n"); if (ConfigureParams.HardDisk.bUseHardDiskDirectories) Log_Printf(LOG_WARN, "Cartridge can't be used together with GEMDOS hard disk emulation!\n"); } /* Use internal cartridge when user wants extended VDI resolution or * GEMDOS HD. But don't use it on TOS 0.00, it does not work there. */ if ((bUseVDIRes || ConfigureParams.HardDisk.bUseHardDiskDirectories) && TosVersion >= 0x100) { /* Copy built-in cartridge data into the cartridge memory of the ST */ memcpy(&RomMem[0xfa0000], Cart_data, sizeof(Cart_data)); PatchIllegal = true; } else if (strlen(ConfigureParams.Rom.szCartridgeImageFileName) > 0) { /* Load external image file: */ Cart_LoadImage(); } if (PatchIllegal == true) { //fprintf ( stderr ," Cart_ResetImage patch\n" ); /* Hatari's specific illegal opcodes for HD emulation */ cpufunctbl[GEMDOS_OPCODE] = OpCode_GemDos; /* 0x0008 */ cpufunctbl[SYSINIT_OPCODE] = OpCode_SysInit; /* 0x000a */ cpufunctbl[VDI_OPCODE] = OpCode_VDI; /* 0x000c */ } else { //fprintf ( stderr ," Cart_ResetImage no patch\n" ); /* No built-in cartridge loaded : set same handler as 0x4afc (illegal) */ cpufunctbl[GEMDOS_OPCODE] = cpufunctbl[ 0x4afc ]; /* 0x0008 */ cpufunctbl[SYSINIT_OPCODE] = cpufunctbl[ 0x4afc ]; /* 0x000a */ cpufunctbl[VDI_OPCODE] = cpufunctbl[ 0x4afc ]; /* 0x000c */ } /* although these don't need cartridge code, it's better * to configure all illegal opcodes in same place... */ if (ConfigureParams.Log.bNatFeats) { /* illegal opcodes for emulators Native Features */ cpufunctbl[NATFEAT_ID_OPCODE] = OpCode_NatFeat_ID; /* 0x7300 */ cpufunctbl[NATFEAT_CALL_OPCODE] = OpCode_NatFeat_Call; /* 0x7301 */ } else { /* No Native Features : set same handler as 0x4afc (illegal) */ cpufunctbl[NATFEAT_ID_OPCODE] = cpufunctbl[ 0x4afc ]; /* 0x7300 */ cpufunctbl[NATFEAT_CALL_OPCODE] = cpufunctbl[ 0x4afc ]; /* 0x7300 */ } }