ASAVE, LOAD #F8, remove JMP, 0000R syntax

This commit is contained in:
nino-porcino 2022-03-30 11:42:53 +02:00
parent 9e0651061c
commit cf126ede50
3 changed files with 96 additions and 22 deletions

21
demos/sdcard/cmd_asave.h Normal file
View File

@ -0,0 +1,21 @@
// AppleSoft BASIC lite definitions
word const *TXTTAB = (word *) 0x0067;
word const *VARTAB = (word *) 0x0069;
word const *PRGEND = (word *) 0x00AF;
void comando_asave() {
woz_puts("SAVING\r");
// appends #F8 + start address (normally: "0801")
tmpword = (word) *TXTTAB;
strcat(filename, "#F8");
append_hex_tmpword(filename);
// launches a normal file write from start_address to end_address
start_address = (word) *TXTTAB;
end_address = (word) *PRGEND;
end_address--;
comando_write();
}

View File

@ -41,13 +41,14 @@ void comando_load_bas() {
if(*token_ptr == '#') {
if(token_ptr[1] == '0' && token_ptr[2] == '6') { filetype = 0x06; break; }
if(token_ptr[1] == 'F' && token_ptr[2] == '1') { filetype = 0xF1; break; }
if(token_ptr[1] == 'F' && token_ptr[2] == '8') { filetype = 0xF8; break; }
}
if(*token_ptr == 0) break;
token_ptr++;
}
// calculate start address for 0x06 binary file
if(filetype == 0x06) {
if(filetype == 0x06 || filetype == 0xF8) {
token_ptr+=2;
hex_to_word(token_ptr);
start_address = tmpword;
@ -57,7 +58,7 @@ void comando_load_bas() {
receive_word_from_mcu();
if(TIMEOUT) return;
if(filetype != 0x06 && filetype != 0xF1) {
if(filetype == 0) {
woz_puts("?INVALID FILE NAME TAG #");
for(word t=0;t!=tmpword;t++) receive_byte_from_MCU(); // empty buffer
return;
@ -103,6 +104,49 @@ void comando_load_bas() {
return;
}
if(filetype == 0xF8) {
// 0xF8 APPLESOFT BASIC LITE
*TXTTAB = start_address;
// get file bytes
token_ptr = (byte *) start_address;
for(word t=0;t!=tmpword;t++) {
byte data = receive_byte_from_MCU();
if(TIMEOUT) return;
*token_ptr++ = data;
}
*VARTAB = (word) token_ptr;
*PRGEND = (word) token_ptr;
// decrease by one for display result
token_ptr--;
// print feedback to user
woz_putc('\r');
woz_puts(filename);
woz_puts("\r$");
woz_print_hexword(start_address);
woz_puts("-$");
woz_print_hexword((word)token_ptr);
woz_puts(" (");
utoa(tmpword, filename, 10); // use filename as string buffer
woz_puts(filename);
woz_puts(" BYTES)\rOK");
// executes machine language program at start address
//if(cmd == CMD_RUN) {
// woz_putc('\r');
// tmpword = start_address;
// asm {
// jmp (tmpword)
// }
//}
return;
}
// 0xF1 BASIC FILE TYPE
// get file bytes

View File

@ -29,8 +29,8 @@ const byte CMD_RUN = 5;
const byte CMD_SAVE = 6;
const byte CMD_TYPE = 7;
const byte CMD_DUMP = 8;
const byte CMD_JMP = 9;
const byte CMD_BAS = 10;
const byte CMD_ASAVE = 9;
const byte CMD_BAS = 10;
const byte CMD_DEL = 11;
const byte CMD_LS = 12;
const byte CMD_CD = 13;
@ -44,7 +44,7 @@ const byte CMD_TEST = 20;
const byte CMD_HELP = 21;
const byte CMD_QMARK = 22;
const byte CMD_MOUNT = 23;
const byte CMD_EXIT = 24;
const byte CMD_EXIT = 25;
// the list of recognized commands
byte *DOS_COMMANDS[] = {
@ -57,7 +57,7 @@ byte *DOS_COMMANDS[] = {
"SAVE",
"TYPE",
"DUMP",
"JMP",
"ASAVE",
"BAS",
"DEL",
"LS",
@ -75,9 +75,9 @@ byte *DOS_COMMANDS[] = {
"EXIT"
};
// chesum table
// checksum table
byte chksum_table[] = {
0xa7,0xe9,0xf8,0xef,0xeb,0xfe,0xef,0xee,0x8a,0xe8,0xf3,0xa7,0xa7,0xeb,0xe4,0xfe,0xe5,0xe4,0xe3,0xe4,0xe5,0x8a,0xfa,0xe5,0xf8,0xe9,0xe3,0xe4,0xe5,0x8a,0x8a,0x8a,0x82,0xf9,0xe5,0xec,0xfe,0xfd,0xeb,0xf8,0xef,0x83,0xa7,0xe9,0xe6,0xeb,0xff,0xee,0xe3,0xe5,0x8a,0xfa,0xeb,0xf8,0xe7,0xe3,0xed,0xe3,0xeb,0xe4,0xe3,0x8a,0x82,0xe2,0xeb,0xf8,0xee,0xfd,0xeb,0xf8,0xef,0x83,0xa7,0x00
0x80,0x80,0x80,0x8a,0xf3,0xe5,0xff,0x8a,0xe0,0xff,0xf9,0xfe,0x8a,0xec,0xe5,0xff,0xe4,0xee,0x8a,0xeb,0xe4,0x8a,0xef,0xeb,0xf9,0xfe,0xef,0xf8,0x8a,0xef,0xed,0xed,0x8b,0x8b,0x8a,0x80,0x80,0x80,0xa7,0xa7,0xeb,0xff,0xfe,0xe2,0xe5,0xf8,0xf9,0x90,0xa7,0xa7,0xeb,0xe4,0xfe,0xe5,0xe4,0xe3,0xe4,0xe5,0x8a,0xfa,0xe5,0xf8,0xe9,0xe3,0xe4,0xe5,0x8a,0x8a,0x8a,0x82,0xf9,0xe5,0xec,0xfe,0xfd,0xeb,0xf8,0xef,0x83,0xa7,0xe9,0xe6,0xeb,0xff,0xee,0xe3,0xe5,0x8a,0xfa,0xeb,0xf8,0xe7,0xe3,0xed,0xe3,0xeb,0xe4,0xe3,0x8a,0x82,0xe2,0xeb,0xf8,0xee,0xfd,0xeb,0xf8,0xef,0x83,0xa7,0x00
};
// parse a string, get the first string delimited by space or end of string
@ -167,8 +167,9 @@ void append_hex_tmpword(char *dest) {
#include "cmd_read.h"
#include "cmd_write.h"
#include "cmd_load.h"
#include "cmd_save.h"
#include "cmd_asave.h"
#include "cmd_load.h"
#include "cmd_type.h"
#include "cmd_dump.h"
#include "cmd_del.h"
@ -325,6 +326,14 @@ void console() {
comando_save_bas();
}
}
else if(cmd == CMD_ASAVE) {
get_token(filename, 32); // parse filename
if(filename[0] == 0) {
woz_puts("?MISSING FILENAME");
continue;
}
comando_asave();
}
else if(cmd == CMD_TYPE) {
get_token(filename, 32); // parse filename
if(filename[0] == 0) {
@ -356,17 +365,6 @@ void console() {
}
comando_dump();
}
else if(cmd == CMD_JMP) {
get_token(hex1, 4); // parse hex
hex_to_word(hex1);
if(!hex_to_word_ok) {
woz_puts("?BAD ARGUMENT");
continue;
}
asm {
jmp (tmpword)
}
}
else if(cmd == CMD_BAS) {
woz_puts("BAS ");
bas_info();
@ -417,10 +415,21 @@ void console() {
woz_mon();
}
else {
if(strlen(command)!=0) {
byte l = strlen(command);
if(l!=0) {
// attempt to parse XXXXR
if(command[l-1] == 'R') {
command[l-1] = 0;
hex_to_word(command);
if(hex_to_word_ok) {
asm {
jmp (tmpword)
}
}
}
woz_puts(command);
woz_puts("??");
}
}
}
if(TIMEOUT) {