arturo-fixed-files-branch #4

Merged
Kittycannon merged 2 commits from arturo-fixed-files-branch into main 2026-04-01 16:38:57 +00:00
3 changed files with 25 additions and 15 deletions
Showing only changes of commit f82aa627c4 - Show all commits

View File

@@ -80,7 +80,7 @@ namespace spider {
_opers[1] = _opers[0];
// call specific addressing mode
(this->*(CPU::addrModes[_addrm]))();
(this->*(CPU::addrModes[_addrm & 0b111]))(); // mask added here too
}
void CPU::fetchOperSrc() {
@@ -88,17 +88,19 @@ namespace spider {
_alu = &ALU1;
// call specific addressing mode
(this->*(CPU::addrModes[_addrm]))();
(this->*(CPU::addrModes[_addrm & 0b111]))(); // mask keeps index within 0-7
// modify the _addrm register
_addrm = static_cast<u8>((_addrm >> 3) & 0x1F);
_addrm++;
}
void CPU::execute() {
(this->*(CPU::addrModes[_opcode]))();
(this->*(CPU::instrMap[_opcode]))(); // no null check needed
}
// Addressing Modes //
/**
@@ -145,6 +147,7 @@ namespace spider {
// get byte
u8 reg = (_reel->readU8(RI) >> sh) & 0xF;
_alu = &GPR[reg];
_opers[0] = _alu; // explicitly sets _opers[0] = _dst
RI += use;
// store no-op

View File

@@ -330,18 +330,16 @@ namespace spider {
int liveDebugMain() {
Terminal t;
Runtime runtime(1024);
InstrReelFixed fix(100);
runtime.ram[0] = 0xFF;
runtime.ram[1] = 0xEE;
runtime.ram[2] = 0xDD;
runtime.ram[3] = 0xCC;
runtime.ram[4] = 0xBB;
runtime.ram[5] = 0xAA;
runtime.ram[6] = 0x99;
runtime.ram[7] = 0x88;
fix.writeU16(0, 0b0000111);
runtime.hookReel(&fix, false);
bool running = true, update = true;
u64 ramScroll = 0;
u8 key = Terminal::UNKNOWN;
@@ -388,7 +386,7 @@ namespace spider {
case Terminal::ENTER:
update = true;
runtime.cpu.fetchInstr();
runtime.cpu.fetchOperDst();
runtime.cpu.execute(); // looks up instrMap[_opcode] & calls the correct instruction method (e.g. FMUL)
break;
default:
break;

View File

@@ -11,8 +11,15 @@
#include <termios.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/ioctl.h> //This was missing,
//The ioctl, TIOCGWINSZ and winsize used in getSize() live in that header, but it was never included.
#endif
//the Linux includes at the top are inside #if SPIDER_OS_LINUX which IS defined,
//but getSize() is inside #if SPIDER_DISTRO_DESKTOP which is NOT defined,
//so the compiler sees the ioctl call without the include that would have covered it.
#if defined(SPIDER_DISTRO_DESKTOP)
namespace spider {
@@ -218,7 +225,8 @@ namespace spider {
struct termios oldt, newt;
tcgetattr(STDIN_FILENO, &oldt);
newt = oldt;
newt.c_lflag &= ~(ICANON | ECHO);
//newt.c_lflag &= ~(ICANON | ECHO);
newt.c_lflag &= static_cast<tcflag_t>(~(ICANON | ECHO)); //added this line
tcsetattr(STDIN_FILENO, TCSANOW, &newt);
u8 result = Terminal::UNKNOWN;
@@ -247,7 +255,8 @@ namespace spider {
}
} else if (ch == 10) result = Terminal::ENTER;
else if (ch == 127) result = Terminal::BACKSPACE;
else result = (u8)ch;
else result = static_cast<u8>(ch); //added this line
//else result = (u8)ch;
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
return result;