2022-02-10 16:06:16 +00:00
|
|
|
// gloabl start_address
|
|
|
|
// global end_address
|
|
|
|
// gloabl len
|
|
|
|
|
|
|
|
void comando_write() {
|
2022-02-07 07:50:35 +00:00
|
|
|
|
|
|
|
// send command byte
|
|
|
|
send_byte_to_MCU(CMD_WRITE);
|
|
|
|
if(TIMEOUT) return;
|
|
|
|
|
|
|
|
// send filename
|
|
|
|
send_string_to_MCU(filename);
|
|
|
|
if(TIMEOUT) return;
|
|
|
|
|
|
|
|
// get first response
|
|
|
|
byte response = receive_byte_from_MCU();
|
|
|
|
if(TIMEOUT) return;
|
|
|
|
if(response == ERR_RESPONSE) {
|
|
|
|
// error with file, print message
|
|
|
|
print_string_response();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// send file size
|
2022-02-10 16:06:16 +00:00
|
|
|
//tmpword = (word) end_address - (word) start_address + 1; // KickC bug: (word) cast is needed
|
|
|
|
asm {
|
|
|
|
sec
|
|
|
|
lda end_address
|
|
|
|
sbc start_address
|
|
|
|
sta tmpword
|
|
|
|
lda end_address+1
|
|
|
|
sbc start_address+1
|
|
|
|
sta tmpword+1
|
|
|
|
}
|
|
|
|
tmpword++;
|
|
|
|
|
|
|
|
send_word_to_mcu();
|
2022-02-07 07:50:35 +00:00
|
|
|
if(TIMEOUT) return;
|
|
|
|
|
|
|
|
// send actual bytes
|
2022-02-10 16:06:16 +00:00
|
|
|
token_ptr = (byte *) start_address;
|
|
|
|
for(word t=0;t<tmpword;t++) {
|
|
|
|
send_byte_to_MCU(*token_ptr++);
|
2022-02-07 07:50:35 +00:00
|
|
|
if(TIMEOUT) return;
|
2022-02-10 16:06:16 +00:00
|
|
|
|
|
|
|
#ifdef LOADING_DOTS
|
2022-02-07 07:50:35 +00:00
|
|
|
if(((byte)t) == 0) woz_putc('.');
|
2022-02-10 16:06:16 +00:00
|
|
|
#endif
|
2022-02-07 07:50:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// get second response
|
|
|
|
response = receive_byte_from_MCU();
|
|
|
|
if(TIMEOUT) return;
|
|
|
|
if(response == ERR_RESPONSE) {
|
|
|
|
// error with file, print message
|
|
|
|
print_string_response();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// print feedback to user
|
|
|
|
woz_putc('\r');
|
|
|
|
woz_puts(filename);
|
|
|
|
woz_puts(": ");
|
2022-02-10 16:06:16 +00:00
|
|
|
woz_print_hexword(start_address);
|
2022-02-07 07:50:35 +00:00
|
|
|
woz_putc('.');
|
2022-02-10 16:06:16 +00:00
|
|
|
woz_print_hexword(end_address);
|
2022-02-07 07:50:35 +00:00
|
|
|
woz_puts(" (");
|
2022-02-10 16:06:16 +00:00
|
|
|
utoa(tmpword, filename, 10); // use filename as string buffer
|
2022-02-07 07:50:35 +00:00
|
|
|
woz_puts(filename);
|
|
|
|
woz_puts(" BYTES)\rOK");
|
|
|
|
}
|