Whitespace
This commit is contained in:
parent
02e49932ea
commit
762f8f5e6d
51
src/main.c
51
src/main.c
|
@ -68,7 +68,7 @@ static void run(v6502_cpu *cpu) {
|
||||||
wmove(pia->screen, 0, 0);
|
wmove(pia->screen, 0, 0);
|
||||||
consoleMessageSeen++;
|
consoleMessageSeen++;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!faulted && !pia->signalled) {
|
while (!faulted && !pia->signalled) {
|
||||||
if (v6502_breakpointIsInList(breakpoint_list, cpu->pc)) {
|
if (v6502_breakpointIsInList(breakpoint_list, cpu->pc)) {
|
||||||
pia_stop(pia);
|
pia_stop(pia);
|
||||||
|
@ -91,8 +91,7 @@ static const char *prompt() {
|
||||||
return prompt;
|
return prompt;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char * argv[])
|
int main(int argc, const char *argv[]) {
|
||||||
{
|
|
||||||
currentFileName = "apple1";
|
currentFileName = "apple1";
|
||||||
|
|
||||||
cpu = v6502_createCPU();
|
cpu = v6502_createCPU();
|
||||||
|
@ -102,7 +101,7 @@ int main(int argc, const char * argv[])
|
||||||
|
|
||||||
breakpoint_list = v6502_createBreakpointList();
|
breakpoint_list = v6502_createBreakpointList();
|
||||||
table = as6502_createSymbolTable();
|
table = as6502_createSymbolTable();
|
||||||
|
|
||||||
// Load Woz Monitor
|
// Load Woz Monitor
|
||||||
printf("Loading ROM...\n");
|
printf("Loading ROM...\n");
|
||||||
if (!v6502_loadFileAtAddress(cpu->memory, DEFAULT_FILENAME_ROM, RESET_VECTOR)) {
|
if (!v6502_loadFileAtAddress(cpu->memory, DEFAULT_FILENAME_ROM, RESET_VECTOR)) {
|
||||||
|
@ -110,7 +109,7 @@ int main(int argc, const char * argv[])
|
||||||
}
|
}
|
||||||
//v6502_map(cpu->memory, start, ROM_SIZE, romMirrorCallback, NULL, NULL);
|
//v6502_map(cpu->memory, start, ROM_SIZE, romMirrorCallback, NULL, NULL);
|
||||||
|
|
||||||
// Load integer BASIC
|
// Load integer BASIC
|
||||||
FILE *file = fopen(DEFAULT_FILENAME_BASIC, "r");
|
FILE *file = fopen(DEFAULT_FILENAME_BASIC, "r");
|
||||||
if (file) {
|
if (file) {
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
@ -130,10 +129,10 @@ int main(int argc, const char * argv[])
|
||||||
// Attach PIA
|
// Attach PIA
|
||||||
printf("Initializing PIA...\n");
|
printf("Initializing PIA...\n");
|
||||||
pia = pia_create(cpu);
|
pia = pia_create(cpu);
|
||||||
|
|
||||||
printf("Resetting CPU...\n");
|
printf("Resetting CPU...\n");
|
||||||
v6502_reset(cpu);
|
v6502_reset(cpu);
|
||||||
|
|
||||||
printf("Running...\n");
|
printf("Running...\n");
|
||||||
run(cpu);
|
run(cpu);
|
||||||
|
|
||||||
|
@ -141,7 +140,7 @@ int main(int argc, const char * argv[])
|
||||||
HistEvent ev;
|
HistEvent ev;
|
||||||
History *hist = history_init();
|
History *hist = history_init();
|
||||||
history(hist, &ev, H_SETSIZE, 100);
|
history(hist, &ev, H_SETSIZE, 100);
|
||||||
|
|
||||||
EditLine *el = el_init(currentFileName, stdin, stdout, stderr);
|
EditLine *el = el_init(currentFileName, stdin, stdout, stderr);
|
||||||
el_set(el, EL_PROMPT, &prompt);
|
el_set(el, EL_PROMPT, &prompt);
|
||||||
el_set(el, EL_SIGNAL, SIGWINCH);
|
el_set(el, EL_SIGNAL, SIGWINCH);
|
||||||
|
@ -149,27 +148,27 @@ int main(int argc, const char * argv[])
|
||||||
el_set(el, EL_HIST, history, hist);
|
el_set(el, EL_HIST, history, hist);
|
||||||
el_set(el, EL_ADDFN, "tab-complete", "Tab completion", v6502_completeDebuggerCommand);
|
el_set(el, EL_ADDFN, "tab-complete", "Tab completion", v6502_completeDebuggerCommand);
|
||||||
el_set(el, EL_BIND, "\t", "tab-complete", NULL);
|
el_set(el, EL_BIND, "\t", "tab-complete", NULL);
|
||||||
|
|
||||||
char *command = NULL;
|
char *command = NULL;
|
||||||
while (!feof(stdin)) {
|
while (!feof(stdin)) {
|
||||||
currentLineNum++;
|
currentLineNum++;
|
||||||
|
|
||||||
const char *in = el_gets(el, &commandLen);
|
const char *in = el_gets(el, &commandLen);
|
||||||
if (!in) {
|
if (!in) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
history(hist, &ev, H_ENTER, in);
|
history(hist, &ev, H_ENTER, in);
|
||||||
command = realloc(command, commandLen + 1);
|
command = realloc(command, commandLen + 1);
|
||||||
memcpy(command, in, commandLen);
|
memcpy(command, in, commandLen);
|
||||||
|
|
||||||
// Trim newline, always the last char
|
// Trim newline, always the last char
|
||||||
command[commandLen - 1] = '\0';
|
command[commandLen - 1] = '\0';
|
||||||
|
|
||||||
if (command[0] == '\0') {
|
if (command[0] == '\0') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v6502_handleDebuggerCommand(cpu, command, commandLen, breakpoint_list, table, run, &verbose)) {
|
if (v6502_handleDebuggerCommand(cpu, command, commandLen, breakpoint_list, table, run, &verbose)) {
|
||||||
if (v6502_compareDebuggerCommand(command, commandLen, "help")) {
|
if (v6502_compareDebuggerCommand(command, commandLen, "help")) {
|
||||||
printf("woz Print relevant woz monitor parameters and registers.\n");
|
printf("woz Print relevant woz monitor parameters and registers.\n");
|
||||||
|
@ -190,19 +189,19 @@ int main(int argc, const char * argv[])
|
||||||
"YSAV 0x%02x\n"
|
"YSAV 0x%02x\n"
|
||||||
"MODE 0x%02x\n",
|
"MODE 0x%02x\n",
|
||||||
v6502_read(cpu->memory, A1PIA_KEYBOARD_INPUT_REGISTER, NO),
|
v6502_read(cpu->memory, A1PIA_KEYBOARD_INPUT_REGISTER, NO),
|
||||||
v6502_read(cpu->memory, 0x24, NO), // XAML
|
v6502_read(cpu->memory, 0x24, NO), // XAML
|
||||||
v6502_read(cpu->memory, 0x25, NO), // XAMH
|
v6502_read(cpu->memory, 0x25, NO), // XAMH
|
||||||
v6502_read(cpu->memory, 0x26, NO), // STL
|
v6502_read(cpu->memory, 0x26, NO), // STL
|
||||||
v6502_read(cpu->memory, 0x27, NO), // STH
|
v6502_read(cpu->memory, 0x27, NO), // STH
|
||||||
v6502_read(cpu->memory, 0x28, NO), // L
|
v6502_read(cpu->memory, 0x28, NO), // L
|
||||||
v6502_read(cpu->memory, 0x29, NO), // H
|
v6502_read(cpu->memory, 0x29, NO), // H
|
||||||
v6502_read(cpu->memory, 0x2A, NO), // YSAV
|
v6502_read(cpu->memory, 0x2A, NO), // YSAV
|
||||||
v6502_read(cpu->memory, 0x2B, NO));// MODE
|
v6502_read(cpu->memory, 0x2B, NO)); // MODE
|
||||||
}
|
}
|
||||||
else if (v6502_compareDebuggerCommand(command, commandLen, "nonstop")) {
|
else if (v6502_compareDebuggerCommand(command, commandLen, "nonstop")) {
|
||||||
// char *trimmedCommand = trimheadtospc(command, commandLen);
|
// char *trimmedCommand = trimheadtospc(command, commandLen);
|
||||||
//
|
//
|
||||||
// if(trimmedCommand[0]) {
|
// if (trimmedCommand[0]) {
|
||||||
printf("Nonstop mode %d -> %d\n", continuousMode, !continuousMode);
|
printf("Nonstop mode %d -> %d\n", continuousMode, !continuousMode);
|
||||||
continuousMode = !continuousMode;
|
continuousMode = !continuousMode;
|
||||||
// }
|
// }
|
||||||
|
@ -213,7 +212,7 @@ int main(int argc, const char * argv[])
|
||||||
else if (v6502_compareDebuggerCommand(command, commandLen, "freeze")) {
|
else if (v6502_compareDebuggerCommand(command, commandLen, "freeze")) {
|
||||||
char *trimmedCommand = trimheadtospc(command, commandLen);
|
char *trimmedCommand = trimheadtospc(command, commandLen);
|
||||||
|
|
||||||
if(trimmedCommand[0]) {
|
if (trimmedCommand[0]) {
|
||||||
saveFreeze(pia, trimmedCommand);
|
saveFreeze(pia, trimmedCommand);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -223,7 +222,7 @@ int main(int argc, const char * argv[])
|
||||||
else if (v6502_compareDebuggerCommand(command, commandLen, "restore")) {
|
else if (v6502_compareDebuggerCommand(command, commandLen, "restore")) {
|
||||||
char *trimmedCommand = trimheadtospc(command, commandLen);
|
char *trimmedCommand = trimheadtospc(command, commandLen);
|
||||||
|
|
||||||
if(trimmedCommand[0]) {
|
if (trimmedCommand[0]) {
|
||||||
loadFreeze(pia, trimmedCommand);
|
loadFreeze(pia, trimmedCommand);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -235,7 +234,7 @@ int main(int argc, const char * argv[])
|
||||||
as6502_executeAsmLineOnCPU(cpu, command, strlen(command));
|
as6502_executeAsmLineOnCPU(cpu, command, strlen(command));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
as6502_destroySymbolTable(table);
|
as6502_destroySymbolTable(table);
|
||||||
v6502_destroyBreakpointList(breakpoint_list);
|
v6502_destroyBreakpointList(breakpoint_list);
|
||||||
history_end(hist);
|
history_end(hist);
|
||||||
|
|
14
src/pia.c
14
src/pia.c
|
@ -93,7 +93,7 @@ uint8_t a1CharFromAsciiChar(unsigned char c) {
|
||||||
if (c >= 'a' && c <= 'z') {
|
if (c >= 'a' && c <= 'z') {
|
||||||
c -= 0x20;
|
c -= 0x20;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (char)c | 0x80;
|
return (char)c | 0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,11 +130,11 @@ uint8_t keyboardReadReadyCallback(struct _v6502_memory *memory, uint16_t offset,
|
||||||
if (!trap) {
|
if (!trap) {
|
||||||
return 0xbf;
|
return 0xbf;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context->buf) {
|
if (context->buf) {
|
||||||
return KEYBOARD_READY;
|
return KEYBOARD_READY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context->suspended) {
|
if (context->suspended) {
|
||||||
printf("Keyboard readiness register ($D011) trap read.\n");
|
printf("Keyboard readiness register ($D011) trap read.\n");
|
||||||
printf("Press a key for input to keyboard register ($D010): ");
|
printf("Press a key for input to keyboard register ($D010): ");
|
||||||
|
@ -163,17 +163,17 @@ uint8_t keyboardReadReadyCallback(struct _v6502_memory *memory, uint16_t offset,
|
||||||
attroff(A_REVERSE);
|
attroff(A_REVERSE);
|
||||||
wmove(context->screen, y, x);
|
wmove(context->screen, y, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c == '`') {
|
if (c == '`') {
|
||||||
context->signalled++;
|
context->signalled++;
|
||||||
return KEYBOARD_NOTREADY;
|
return KEYBOARD_NOTREADY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c != ERR) {
|
if (c != ERR) {
|
||||||
context->buf = asciiCharFromCursesKey(c);
|
context->buf = asciiCharFromCursesKey(c);
|
||||||
return KEYBOARD_READY;
|
return KEYBOARD_READY;
|
||||||
}
|
}
|
||||||
|
|
||||||
return KEYBOARD_NOTREADY;
|
return KEYBOARD_NOTREADY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ uint8_t keyboardReadCharacterCallback(struct _v6502_memory *memory, uint16_t off
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue