summaryrefslogtreecommitdiff
path: root/sux.c
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2020-08-08 10:28:36 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2020-08-08 10:28:36 -0400
commit1ec19679b3db209429b0897f6ccda6d09d018a70 (patch)
treeef17e28b388a04fadeb14982a5332eb647981d8b /sux.c
parent39081609ec4f1f5d96e15e346eecd09ca2cc9f41 (diff)
Did a ton of stuff.
- Changed the file structure of the SuB Suite, so that all variable declarations, symbols, and constants are in a single file. - Moved the C library functionss into a separate file, and made them use stack frames. - Added support for using the emulator's assembler for realtime debugging, to enter it, get in to stepping mode by pressing Ctrl+s, press any other key, then press F1, The reason for having to press some other key before pressing F1 is because it only allows entering the assembler when the keyboard is not ready. - Added the ".res" directive to the emulator's assembler, the ".res" directive tells the assembler to reserve however many bytes specified by the operand. - Fixed some bugs in the emulator's assembler.
Diffstat (limited to 'sux.c')
-rw-r--r--sux.c73
1 files changed, 57 insertions, 16 deletions
diff --git a/sux.c b/sux.c
index ae99a8b..f6d01e7 100644
--- a/sux.c
+++ b/sux.c
@@ -145,6 +145,11 @@ void *run(void *args) {
#endif
if (optype[opcode] != IMPL) {
address.u64 = get_addr(cpu, &tmpaddr, opcode, prefix, thread);
+
+ if (address.u64 > mem_size-1) {
+ addr[STEP_ADDR] = 1;
+ step = 1;
+ }
setreg_sw(value.u8, 0, addr, address.u64, prefix, 0, RS);
if (optype[opcode] == REL) {
switch ((prefix >> 4) & 3) {
@@ -531,10 +536,26 @@ void *run(void *args) {
return NULL;
}
+void init_scr() {
+ if (!scr) {
+ scr = initscr();
+ }
+ nodelay(stdscr, 0);
+ crmode();
+ noecho();
+ nl();
+ curs_set(1);
+ scrollok(scr, 1);
+ start_color();
+ use_default_colors();
+ init_pair(1, COLOR_WHITE, -1);
+ attron(COLOR_PAIR(1) | A_BOLD);
+}
+
int main(int argc, char **argv) {
struct suxthr thr[THREADS];
char *tmp = malloc(2048);
- addr = malloc(0x04000000);
+ addr = malloc(mem_size);
#if bench
inss = 0;
#endif
@@ -546,7 +567,7 @@ int main(int argc, char **argv) {
}
} else {
#if debug
- subdbg = !strcmp(argv[1], "programs/sub-suite/subeditor.s");
+ subdbg = !strcmp(argv[1], "programs/sub-suite/subsuite.s");
#endif
if (asmmon(argv[1]) == 2) {
return 0;
@@ -555,20 +576,8 @@ int main(int argc, char **argv) {
sprintf(tmp, "\033[2J\033[H");
fwrite(tmp, sizeof(char), strlen(tmp), stdout);
fflush(stdout);
- if(!scr) {
- scr = initscr();
- }
- nodelay(stdscr, 0);
- crmode();
- noecho();
- nl();
- curs_set(1);
+ init_scr();
werase(scr);
- scrollok(scr, 1);
- start_color();
- use_default_colors();
- init_pair(1, COLOR_WHITE, -1);
- attron(COLOR_PAIR(1) | A_BOLD);
wmove(scr, 0, 0);
wrefresh(scr);
pthread_t therads[THREADS];
@@ -628,7 +637,38 @@ int main(int argc, char **argv) {
#if keypoll
pthread_mutex_lock(&mutex);
#endif
- c = wgetch(scr);
+ if (step) {
+ keypad(scr, 1);
+ c = wgetch(scr);
+ if (c != 19 && c != 18 && c != 0x11 && !isalnum(c)) {
+ /*WINDOW *w;
+ int maxcol = getmaxx(scr)/2;
+ int maxrow = getmaxy(scr)/2;*/
+ switch (c) {
+ case KEY_F(1):
+ /*w = newwin(maxrow, maxcol, maxrow, maxcol);
+ emumon(w);
+ delwin(w);*/
+ endwin();
+ puts("Starting asmmon()");
+ asmmon("stdin");
+ puts("Reinitializing screen.");
+ init_scr();
+ wrefresh(scr);
+ break;
+ }
+ #if debug && !bench
+ wmove(scr, getmaxy(scr)-1, 0);
+ wclrtoeol(scr);
+ wprintw(scr, "c: %i", c);
+ wmove(scr, y, x);
+ #endif
+ c = 0;
+ }
+ keypad(scr, 0);
+ } else {
+ c = wgetch(scr);
+ }
if (c == 19) {
if (kbd_rdy) {
c = wgetch(scr);
@@ -643,6 +683,7 @@ int main(int argc, char **argv) {
case ERR:
addr[CTRL_ADDR] = 0;
break;
+ case '\0': break;
default:
if (kbd_rdy && c < 0x100) {
addr[RX_ADDR] = (uint8_t)c;