diff --git a/RunCPM/RunCPM.ino b/RunCPM/RunCPM.ino index cf10b70..e89e29b 100644 --- a/RunCPM/RunCPM.ino +++ b/RunCPM/RunCPM.ino @@ -79,10 +79,25 @@ void setup(void) { _PatchCPM(); Status = 0; #ifndef CCP_INTERNAL - if (!_RamLoad((char *)CCPname, CCPaddr)) { + if (!_RamLoad((uint8 *)CCPname, CCPaddr)) { _puts("Unable to load the CCP.\r\nCPU halted.\r\n"); break; } + // Loads an autoexec file if it exists and this is the first boot + // The file contents are loaded at ccpAddr+8 up to 126 bytes then the size loaded is stored at ccpAddr+7 + if (firstBoot) { + if (_sys_exists((uint8*)AUTOEXEC)) { + uint16 cmd = CCPaddr + 8; + uint8 bytesread = (uint8)_RamLoadSz((uint8*)AUTOEXEC, cmd, 125); + uint8 blen = 0; + while (blen < bytesread && _RamRead(cmd + blen) > 31) + blen++; + _RamWrite(cmd + blen, 0x00); + _RamWrite(--cmd, blen); + } + if (BOOTONLY) + firstBoot = FALSE; + } Z80reset(); SET_LOW_REGISTER(BC, _RamRead(DSKByte)); PC = CCPaddr; diff --git a/RunCPM/abstraction_arduino.h b/RunCPM/abstraction_arduino.h index ef52220..41ccdeb 100644 --- a/RunCPM/abstraction_arduino.h +++ b/RunCPM/abstraction_arduino.h @@ -20,11 +20,11 @@ /* Memory abstraction functions */ /*===============================================================================*/ -bool _RamLoad(char* filename, uint16 address) { +bool _RamLoad(uint8* filename, uint16 address) { File f; bool result = false; - if (f = SD.open(filename, FILE_READ)) { + if (f = SD.open((char*)filename, FILE_READ)) { while (f.available()) _RamWrite(address++, f.read()); f.close(); @@ -32,12 +32,12 @@ bool _RamLoad(char* filename, uint16 address) { } return(result); } -uint16 _RamLoadSz(char* filename, uint16 address, uint16 maxsize) { +uint16 _RamLoadSz(uint8* filename, uint16 address, uint16 maxsize) { File f; bool result = false; uint16 bytesread = 0; - if (f = SD.open(filename, FILE_READ)) { + if (f = SD.open((char*)filename, FILE_READ)) { while (f.available()) { _RamWrite(address++, f.read()); bytesread++;