78b8838cc7
- Complete project skeleton per AGENTS.md (src/, bin/, samples/, attic/ with 1994 code, docs/) - High-performance C core (cpu.c) with most 6809 instructions + selected 6309 - Table-driven disassembler (D) and minimal built-in assembler (A) - Full C64-monitor inspired debugger (R ; M : D A G S B BC F L S ! X ?) - Single step, breakpoints (exec), register/memory view+edit - Robust S-Record, Intel HEX, raw binary load/save (tolerant of CRLF) - 6850 ACIA and 6821 PIA emulation (memory-mapped, registered devices) - CLI: -l load, -g go, -i interactive, --cpu 6309, --acia/--pia bases - Designed for tight integration with cc09 (WINTEK re-creation) - Optimized Makefile for macOS/Linux (clang/gcc, -O3 -flto -march=native) - AGENTS.md with mission, structure, coding rules, monitor reference Verified: builds release+debug, loads provided samples (140A.HEX 2299.HEX 2299.MIK), monitor commands, A/D/S/B, roundtrip save/load. Remote: http://gitea.binary-systems.com/vincente/mimic
170 lines
4.1 KiB
C++
Executable File
170 lines
4.1 KiB
C++
Executable File
#include <stdio.h>
|
|
#include <strings.h>
|
|
#include <ctype.h>
|
|
//#include <stream.h>
|
|
|
|
#define FALSE 0
|
|
#define TRUE 1
|
|
|
|
|
|
void Help()
|
|
{
|
|
printf("usage: mimic <options> <filename>\n");
|
|
}
|
|
|
|
|
|
void Version()
|
|
{
|
|
printf("Mimic 0.001 by Vincente D'Ingianni. Copyright 1994 Mimic.\n");
|
|
}
|
|
|
|
|
|
int getline(char s[], int lim)
|
|
{
|
|
int c, i;
|
|
|
|
for (i = 0; i < lim - 1 && (c = getchar()) != EOF && c != '\n'; ++i)
|
|
s[i] = c;
|
|
if (c == '\n') {
|
|
s[i] = c;
|
|
++i;
|
|
}
|
|
s[i] = '\0';
|
|
return i;
|
|
}
|
|
|
|
|
|
//int getNextHex(char *line)
|
|
//{
|
|
// int value;
|
|
// sscanf(line, "%x", value);
|
|
//
|
|
//}
|
|
|
|
|
|
void Modify(char *line)
|
|
{
|
|
int args;
|
|
unsigned int address;
|
|
char value[15];
|
|
printf("Modify!\n");
|
|
toupper(line[0]);
|
|
|
|
for (int i = 0; i <= 0xF; ++i) value[i] = 0;
|
|
|
|
args = sscanf(line, "M %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x",
|
|
&address,
|
|
&value[0], &value[1], &value[2], &value[3],
|
|
&value[4], &value[5], &value[6], &value[7],
|
|
&value[8], &value[9], &value[0xA], &value[0xB],
|
|
&value[0xC], &value[0xD], &value[0xE], &value[0xF]);
|
|
|
|
printf("args: %d\taddress: %x\n", args, address);
|
|
|
|
while (args > 0) {
|
|
// for (int i = 0; i <= args - 1; i++) Poke(address + i, value[i]);
|
|
|
|
printf("%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n",
|
|
value[0], value[1], value[2], value[3],
|
|
value[4], value[5], value[6], value[7],
|
|
value[8], value[9], value[0xA], value[0xB],
|
|
value[0xC], value[0xD], value[0xE], value[0xF]);
|
|
|
|
for (int i = 0; i <= 0xF; ++i) value[i] = 0;
|
|
address += i;
|
|
args = 0;
|
|
printf(" %x ", address);
|
|
if (getline(line, sizeof(line)) > 0) {
|
|
args = sscanf(line, "%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x",
|
|
&value[0], &value[1], &value[2], &value[3],
|
|
&value[4], &value[5], &value[6], &value[7],
|
|
&value[8], &value[9], &value[0xA], &value[0xB],
|
|
&value[0xC], &value[0xD], &value[0xE], &value[0xF]);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
void Display(unsigned int address)
|
|
{
|
|
int args;
|
|
unsigned int address;
|
|
char value[15];
|
|
printf("Modify!\n");
|
|
toupper(line[0]);
|
|
|
|
|
|
while (args > 0) {
|
|
// for (int i = 0; i <= args - 1; i++) Poke(address + i, value[i]);
|
|
|
|
printf("%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n",
|
|
value[0], value[1], value[2], value[3],
|
|
value[4], value[5], value[6], value[7],
|
|
value[8], value[9], value[0xA], value[0xB],
|
|
value[0xC], value[0xD], value[0xE], value[0xF]);
|
|
|
|
for (int i = 0; i <= 0xF; ++i) value[i] = 0;
|
|
address += i;
|
|
args = 0;
|
|
printf(" %x ", address);
|
|
if (getline(line, sizeof(line)) > 0) {
|
|
args = sscanf(line, "%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x",
|
|
&value[0], &value[1], &value[2], &value[3],
|
|
&value[4], &value[5], &value[6], &value[7],
|
|
&value[8], &value[9], &value[0xA], &value[0xB],
|
|
&value[0xC], &value[0xD], &value[0xE], &value[0xF]);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
void Interactive()
|
|
{
|
|
bool done = FALSE;
|
|
char command;
|
|
char line[255];
|
|
printf("Going interactive.\n");
|
|
|
|
while (!done) {
|
|
printf("Mimic> ");
|
|
if (getline(line, sizeof(line)) > 0) {
|
|
line[0] = toupper(line[0]);
|
|
if (line[0] == 'Q') done = TRUE;
|
|
if (line[0] == 'M') Modify(line);
|
|
if ((args = sscanf(line, "D %x", &address)) == 1) Display(address);
|
|
// if (line[0] == 'D') Display(line);
|
|
if (line[0] == '!') system(&line[1]);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void main(int argc, char *argv[])
|
|
{
|
|
bool interactive = FALSE;
|
|
printf("hello, world\n");
|
|
|
|
if (argc > 1) {
|
|
for (int i = 1; i <= argc; i++) {
|
|
if (strcmp(argv[i], "-v") == 0) {
|
|
Version();
|
|
}
|
|
if (strcmp(argv[i], "-h") == 0) {
|
|
Help();
|
|
}
|
|
if (strcmp(argv[i], "-i") == 0) {
|
|
interactive = TRUE;
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
interactive = TRUE;
|
|
}
|
|
|
|
if (interactive == TRUE) {
|
|
Interactive();
|
|
}
|
|
|
|
}
|