This commit is contained in:
Denis Molony 2021-07-30 06:03:40 +10:00
parent e7d8c4ebc2
commit 068f382c87
1 changed files with 17 additions and 24 deletions

View File

@ -30,13 +30,13 @@ public class CPMBasicFile extends BasicProgram
}; };
String[] functions = { // String[] functions = { //
"", "LEFT$", "RIGHT$", "MID$", "SGN", "INT", "ABS", "SQR", // 0x80 "", "LEFT$", "RIGHT$", "MID$", "SGN", "INT", "ABS", "SQR", // 0x80
"RND", "SIN", "LOG", "EXP", "COS", "TAN", "ATN", "FRE", // 0x88 "RND", "SIN", "LOG", "EXP", "COS", "TAN", "ATN", "FRE", // 0x88
"POS", "LEN", "STR$", "VAL", "ASC", "CHR$", "PEEK", "SPACE$", // 0x90 "POS", "LEN", "STR$", "VAL", "ASC", "CHR$", "PEEK", "SPACE$", // 0x90
"OCT$", "HEX$", "LPOS", "CINT", "CSNG", "CDBL", "FIX", "", // 0x98 "OCT$", "HEX$", "LPOS", "CINT", "CSNG", "CDBL", "FIX", "", // 0x98
"", "", "", "", "", "", "", "", // 0xA0 "", "", "", "", "", "", "", "", // 0xA0
"", "", "CVI", "CVS", "CVD", "", "EOF", "LOC", // 0xA8 "", "", "CVI", "CVS", "CVD", "", "EOF", "LOC", // 0xA8
"", "MKI$", "MKS$", "MKD$", // 0xB0 "", "MKI$", "MKS$", "MKD$", // 0xB0
}; };
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@ -83,7 +83,7 @@ public class CPMBasicFile extends BasicProgram
if (val == 0) if (val == 0)
break; break;
if (val >= 0x80) if ((val & 0x80) != 0)
{ {
if (val == 0xFF) if (val == 0xFF)
{ {
@ -142,26 +142,22 @@ public class CPMBasicFile extends BasicProgram
break; break;
case 0x0C: case 0x0C:
int b1 = buffer[ptr++] & 0xFF; text.append ("&H" + String.format ("%X", Utility.getShort (buffer, ptr)));
int b2 = buffer[ptr++] & 0xFF; ptr += 2;
text.append ("&H" + String.format ("%X", b2 * 256 + b1));
break; break;
case 0x0E: // same as 0x1C ?? case 0x0E: // same as 0x1C ??
b1 = buffer[ptr++] & 0xFF; text.append (Utility.getShort (buffer, ptr));
b2 = buffer[ptr++] & 0xFF; ptr += 2;
text.append (b2 * 256 + b1);
break; break;
case 0x0F: case 0x0F:
int nextVal = buffer[ptr++] & 0xFF; text.append (buffer[ptr++] & 0xFF);
text.append (nextVal);
break; break;
case 0x1C: // same as 0x0E ?? case 0x1C: // same as 0x0E ??
b1 = buffer[ptr++] & 0xFF; text.append (Utility.getShort (buffer, ptr));
b2 = buffer[ptr++] & 0xFF; ptr += 2;
text.append (b2 * 256 + b1);
break; break;
case 0x1D: case 0x1D:
@ -188,10 +184,7 @@ public class CPMBasicFile extends BasicProgram
text.append ("\n"); text.append ("\n");
} }
if (text.length () > 0) return Utility.rtrim (text);
text.deleteCharAt (text.length () - 1);
return text.toString ();
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@ -231,6 +224,6 @@ public class CPMBasicFile extends BasicProgram
HexFormatter.getHexString (buffer, lastPtr + 4, ptr - lastPtr - 4))); HexFormatter.getHexString (buffer, lastPtr + 4, ptr - lastPtr - 4)));
} }
return text.toString (); return Utility.rtrim (text);
} }
} }