Skip to content

Commit

Permalink
fixes to boo boo I just added
Browse files Browse the repository at this point in the history
  • Loading branch information
MockbaTheBorg committed Jun 30, 2024
1 parent 08175cb commit 03d32a5
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 23 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,4 @@ RunCPM/B
RunCPM/C
RunCPM/D
RunCPM/E
.vscode
4 changes: 2 additions & 2 deletions RunCPM/abstraction_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#define HostOS 0x06
#endif

static char baseFolderName[128] = ".\\"; // Base folder name for the CP/M filesystem
uint8 baseFolderName[128] = ".\\"; // Base folder name for the CP/M filesystem

/* Memory abstraction functions */
/*===============================================================================*/
Expand Down Expand Up @@ -374,7 +374,7 @@ uint8 _findnext(uint8 isdir) {
fileExtentsUsed = 0;
firstFreeAllocBlock = firstBlockAfterDir;
}
_RamWrite(tmpFCB, filename[0 + strlen(baseFolderName)] - '@');
_RamWrite(tmpFCB, filename[strlen((char *)baseFolderName)] - '@');
_HostnameToFCB(tmpFCB, findNextDirName);
result = 0x00;
break;
Expand Down
26 changes: 19 additions & 7 deletions RunCPM/abstraction_posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ lua_State* L;

#define HostOS 0x02

static char baseFolderName[128] = "./"; // Base folder name for the CP/M filesystem
uint8 baseFolderName[128] = "./"; // Base folder name for the CP/M filesystem

/* Externals for abstracted functions need to go here */
FILE* _sys_fopen_r(uint8* filename);
Expand Down Expand Up @@ -392,10 +392,22 @@ static uint16 firstFreeAllocBlock;

uint8 _findnext(uint8 isdir) {
uint8 result = 0xff;
char dir[6] = { '?', FOLDERCHAR, 0, FOLDERCHAR, '*', 0 };
char dir[128];
int i;
struct stat st;
uint32 bytes;
uint8 j = 0;

uint8* baseFolder = (uint8*)baseFolderName;
while (*baseFolder)
dir[j++] = *(baseFolder++);
dir[j++] = '?';
dir[j++] = FOLDERCHAR;
dir[j++] = 0;
dir[j++] = FOLDERCHAR;
dir[j++] = '*';
dir[j] = 0;
j -= 5;

if (allExtents && fileRecords) {
// _SearchFirst was called with '?' in the FCB's EX field, so
Expand All @@ -408,12 +420,12 @@ uint8 _findnext(uint8 isdir) {
} else {
// Either we're only interested in the first directory entry
// for each file, or the previously found file has had the
// required number of dierctory entries returned already.
dir[0] = filename[0];
// required number of directory entries returned already.
dir[j] = filename[j];
if (allUsers)
dir[2] = '?';
dir[j + 2] = '?';
else
dir[2] = filename[2];
dir[j + 2] = filename[j + 2];
if (!glob(dir, 0, NULL, &pglob)) {
for (i = dirPos; i < pglob.gl_pathc; ++i) {
++dirPos;
Expand Down Expand Up @@ -449,7 +461,7 @@ uint8 _findnext(uint8 isdir) {
fileExtentsUsed = 0;
firstFreeAllocBlock = firstBlockAfterDir;
}
_RamWrite(tmpFCB, filename[0 + strlen(baseFolderName)] - '@');
_RamWrite(tmpFCB, filename[strlen((char *)baseFolderName)] - '@');
_HostnameToFCB(tmpFCB, (uint8*)findNextDirName);
result = 0x00;
break;
Expand Down
6 changes: 3 additions & 3 deletions RunCPM/abstraction_vstudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ lua_State* L;

#define HostOS 0x00

static char baseFolderName[128] = ".\\"; // Base folder name for the CP/M filesystem
uint8 baseFolderName[128] = ".\\"; // Base folder name for the CP/M filesystem

/* Externals for abstracted functions need to go here */
FILE* _sys_fopen_r(uint8* filename);
Expand Down Expand Up @@ -380,8 +380,8 @@ uint8 _findnext(uint8 isdir) {
fileExtentsUsed = 0;
firstFreeAllocBlock = firstBlockAfterDir;
}
_RamWrite(tmpFCB, filename[0 + strlen(baseFolderName)] - '@'); // Set the requested drive onto the tmp FCB
_HostnameToFCB(tmpFCB, (uint8*)&FindFileData.cFileName[0]); // Set the file name onto the tmp FCB
_RamWrite(tmpFCB, filename[strlen((char *)baseFolderName)] - '@'); // Set the requested drive onto the tmp FCB
_HostnameToFCB(tmpFCB, (uint8*)&FindFileData.cFileName[0]); // Set the file name onto the tmp FCB
result = 0x00;
} else {
FindClose(hFind);
Expand Down
23 changes: 13 additions & 10 deletions RunCPM/disk.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,14 @@ void _HostnameToFCB(uint16 fcbaddr, uint8* filename) {
CPM_FCB* F = (CPM_FCB*)_RamSysAddr(fcbaddr);
uint8 i = 0;

++filename;
if (*filename == FOLDERCHAR) { // Skips the drive and / if needed
filename += 3;
} else {
--filename;
if(filename[0] != '$') {
filename += strlen((char *)baseFolderName);
++filename;
if (*filename == FOLDERCHAR) { // Skips the drive and / if needed
filename += 3;
} else {
--filename;
}
}

while (*filename != 0 && *filename != '.') {
Expand Down Expand Up @@ -176,7 +179,7 @@ void _HostnameToFCB(uint16 fcbaddr, uint8* filename) {
void _HostnameToFCBname(uint8* from, uint8* to) {
int i = 0;

from += strlen(baseFolderName);
from += strlen((char *)baseFolderName);
++from;
if (*from == FOLDERCHAR) { // Skips the drive and / if needed
from += 3;
Expand Down Expand Up @@ -620,16 +623,16 @@ uint8 _MakeDisk(uint16 fcbaddr) {
// Checks if there's a temp submit file present
uint8 _CheckSUB(void) {
uint8 result;
uint8 oCode = userCode; // Saves the current user code (original BDOS does not do this)
uint8 oCode = userCode; // Saves the current user code (original BDOS does not do this)
_HostnameToFCB(tmpFCB, (uint8*)"$???????.???"); // The original BDOS in fact only looks for a file which start with $
#ifdef BATCHA
_RamWrite(tmpFCB, 1); // Forces it to be checked on drive A:
_RamWrite(tmpFCB, 1); // Forces it to be checked on drive A:
#endif
#ifdef BATCH0
userCode = 0; // Forces it to be checked on user 0
userCode = 0; // Forces it to be checked on user 0
#endif
result = (_SearchFirst(tmpFCB, FALSE) == 0x00) ? 0xff : 0x00;
userCode = oCode; // Restores the current user code
userCode = oCode; // Restores the current user code
return(result);
}

Expand Down
2 changes: 1 addition & 1 deletion RunCPM/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ int main(int argc, char* argv[]) {
_puthex16(CCPaddr);
_puts("\r\n");
_puts("Base folder is ");
_puts((uint8*)baseFolderName);
_puts((char *)baseFolderName);
_puts("\r\n");
#if BANKS > 1
_puts("Banked Memory: ");
Expand Down

0 comments on commit 03d32a5

Please sign in to comment.