From 460832c13c9d476d71e626a0c42de4eeff3feb63 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Thu, 11 Jun 2020 21:39:59 -0400 Subject: Did some more stuff. - Fix some bugs with strings. - Started to refactor the instruction functions. - Added support for using RS prefixes on the memory based increment, and decrement instructions. - Started work on SuBAsm's lexer. Have fun looking at this, BieHDC. :) --- io.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'io.c') diff --git a/io.c b/io.c index 9027da9..dc07d52 100644 --- a/io.c +++ b/io.c @@ -4,11 +4,16 @@ uint8_t iscol; uint8_t idx = 3; uint8_t bcd[4]; -void io(uint64_t address, uint8_t *esc) { +void io(uint64_t address, uint8_t rw) { int x, y; uint16_t scr_col = 0; + /*step |= (!rw) ? (cpu->pc[thread] == CTRL_ADDR) : step;*/ switch (address) { + case STEP_ADDR: step = (!rw) ? addr[STEP_ADDR] : step; break; case CTRL_ADDR: + if (!rw) { + break; + } kbd_rdy = 1; pthread_mutex_lock(&main_mutex); pthread_cond_signal(&main_cond); @@ -21,6 +26,9 @@ void io(uint64_t address, uint8_t *esc) { kbd_rdy = 0; break; case TX_ADDR: + if (rw) { + break; + } getyx(scr, y, x); #if debug if (!subdbg) { @@ -28,7 +36,7 @@ void io(uint64_t address, uint8_t *esc) { wmove(scr, 28, scr_col); } #endif - if (*esc) { + if (esc) { #if debug if (!subdbg && addr[RX_ADDR] == '\n') { wclrtoeol(scr); @@ -41,7 +49,7 @@ void io(uint64_t address, uint8_t *esc) { #if !debug wmove(scr, y, x); #endif - *esc = 0; + esc = 0; break; case 'B': if (y < getmaxy(scr)) @@ -49,7 +57,7 @@ void io(uint64_t address, uint8_t *esc) { #if !debug wmove(scr, y, x); #endif - *esc = 0; + esc = 0; break; case 'C': if (x < getmaxx(scr)) @@ -57,7 +65,7 @@ void io(uint64_t address, uint8_t *esc) { #if !debug wmove(scr, y, x); #endif - *esc = 0; + esc = 0; break; case 'D': if (x > 0) @@ -65,7 +73,7 @@ void io(uint64_t address, uint8_t *esc) { #if !debug wmove(scr, y, x); #endif - *esc = 0; + esc = 0; break; case 'H': if (!bcd[2] && !bcd[3]) { @@ -81,29 +89,29 @@ void io(uint64_t address, uint8_t *esc) { #if !debug wmove(scr, y, x); #else - mvwprintw(scr, 30, 0, "x: %i, y: %i ", x, y); - /*mvwprintw(scr, 31, 0, "bcd[3-2]: {%u, %u}, bcd[1-0]: {%u, %u}", bcd[3], bcd[2], bcd[1], bcd[0]);*/ + /*mvwprintw(scr, 31, 0, "x: %i, y: %i ", x, y);*/ + mvwprintw(scr, 31, 0, "bcd[3-2]: {%u, %u}, bcd[1-0]: {%u, %u}", bcd[3], bcd[2], bcd[1], bcd[0]); #endif idx = 3; bcd[0] = 0; bcd[1] = 0; bcd[2] = 0; bcd[3] = 0; - *esc = 0; + esc = 0; break; case 'S': #if !debug wscrl(scr, -1); #else #endif - *esc = 0; + esc = 0; break; case 'T': #if !debug wscrl(scr, 1); #else #endif - *esc = 0; + esc = 0; break; case '0': case '1': @@ -150,9 +158,7 @@ void io(uint64_t address, uint8_t *esc) { } #endif break; - case '\033': - *esc = 1; - break; + case '\033': esc = 1; break; case '\n': x = 0; y+=1; -- cgit v1.2.3-13-gbd6f