Skip to content

Commit

Permalink
MEGA65: Preliminary support: umon (u)mount disks
Browse files Browse the repository at this point in the history
  • Loading branch information
lgblgblgb committed Oct 13, 2022
1 parent 8514c78 commit bee6e9d
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions targets/mega65/uart_monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#warning "Platform does not support UMON"
#else

#include "sdcard.h"

#include "xemu/emutools_socketapi.h"

//#include <sys/types.h>
Expand Down Expand Up @@ -173,8 +175,7 @@ static void execute_command ( char *cmd )
case 'm':
cmd = parse_hex_arg(cmd, &par1, 0, 0xFFFFFFF);
bank = par1 >> 16;
if (cmd && check_end_of_command(cmd, 1))
{
if (cmd && check_end_of_command(cmd, 1)) {
if (bank == 0x777)
m65mon_dumpmem16(par1);
else
Expand All @@ -184,10 +185,8 @@ static void execute_command ( char *cmd )
case 'M':
cmd = parse_hex_arg(cmd, &par1, 0, 0xFFFFFFF);
bank = par1 >> 16;
if (cmd && check_end_of_command(cmd, 1))
{
for (int k = 0; k < 32; k++)
{
if (cmd && check_end_of_command(cmd, 1)) {
for (int k = 0; k < 32; k++) {
if (bank == 0x777)
m65mon_dumpmem16(par1);
else
Expand Down Expand Up @@ -226,14 +225,39 @@ static void execute_command ( char *cmd )
case 0:
m65mon_empty_command(); // emulator can use this, if it wants
break;
case '~':
if (!strncmp(cmd, "exit", 4)) {
XEMUEXIT(0);
} else if (!strncmp(cmd, "mount", 5)) {
// Quite crude syntax for now:
// ~mount0 - unmounting image/disk in drive-0
// ~mount1 - --""-- in drive-1
// ~mount0disk.d81 - mounting "disk81" to drive-0 (yes, no spaces, etc ....)
// So you got it.
cmd += 5;
if (*cmd && (*cmd == '0' || *cmd == '1')) {
const int unit = *cmd - '0';
cmd++;
if (*cmd) {
umon_printf("Mounting %d for: \"%s\"", unit, cmd);
if (!sdcard_force_external_mount(unit, cmd, "Monitor: D81 mount failure")) {
OSD(-1, -1, "Mounted (%d): %s", unit, cmd);
}
} else {
sdcard_unmount(unit);
OSD(-1, -1, "Unmounted (%d)", unit);
}
}
} else
umon_printf(UMON_SYNTAX_ERROR "unknown (or not implemented) Xemu special command: %s", cmd - 1);
break;
default:
umon_printf(UMON_SYNTAX_ERROR "unknown (or not implemented) command '%c'", cmd[-1]);
break;
}
}



/* ------------------------- SOCKET HANDLING, etc ------------------------- */


Expand Down

1 comment on commit bee6e9d

@lgblgblgb
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussion on this: #360

Please sign in to comment.