From 1deb00495d2b7ab19dc29ed2b25c284e56acc85b Mon Sep 17 00:00:00 2001 From: Thiago Auler dos Santos Date: Wed, 22 Nov 2017 23:28:49 -0200 Subject: [PATCH] accepting numbers, text, and other symbols as user input --- src/interface.c | 4 +++- src/opcodes.c | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/interface.c b/src/interface.c index 7019243..450facb 100644 --- a/src/interface.c +++ b/src/interface.c @@ -16,7 +16,9 @@ void input() { int ch = getch(); if (ch == '\n') { ch = '\r'; } - if (ch == '\r' || (ch >= '0' && ch <= '9')) + if (ch == '\r' || ch == '.' || ch == ':' || + (ch >= '0' && ch <= '9') || + (ch >= 'A' && ch <= 'Z')) { keyboard_buffer = ch | 0x80; keyboard_control = 0xFF; diff --git a/src/opcodes.c b/src/opcodes.c index ee3fb74..45a05cd 100644 --- a/src/opcodes.c +++ b/src/opcodes.c @@ -95,7 +95,7 @@ void fetch_operand() void adjustNZ(db r) { - if (r == 0) { Z_SET; } else { Z_UNSET;} + if (r == 0) { Z_SET; } else { Z_UNSET; } r = r >> 7; if (r == 1) { N_SET; } else { N_UNSET; } } @@ -110,7 +110,7 @@ db adder(db a, db b) db z = (a + b + C_IS_SET) >> 7; db v = c ^ z; - if (c == 1) { C_SET; } else { C_UNSET;} + if (c == 1) { C_SET; } else { C_UNSET; } if (v == 1) { V_SET; } else { V_UNSET; } adjustNZ(r); @@ -307,6 +307,7 @@ void clv() void cmp() { // compare memory with accumulator + C_SET; fetch_operand(); operand = operand ^ 0xFF; adder(ac, operand); @@ -315,6 +316,7 @@ void cmp() void cpx() { // compare memory and index x + C_SET; fetch_operand(); operand = operand ^ 0xFF; adder(x, operand); @@ -323,6 +325,7 @@ void cpx() void cpy() { // compare memory and index y + C_SET; fetch_operand(); operand = operand ^ 0xFF; adder(y, operand);