diff --git a/Chip8/Chip8.cpp b/Chip8/Chip8.cpp index d42313c..3ee5b26 100644 --- a/Chip8/Chip8.cpp +++ b/Chip8/Chip8.cpp @@ -304,8 +304,8 @@ void Chip8::Update() { // LD B, Vx char c = regs[x]; - ram[iReg + 2] = c % 10; - ram[iReg + 1] = (c / 10) % 10; + ram[(iReg + 2) & 0xfff] = c % 10; + ram[(iReg + 1) & 0xfff] = (c / 10) % 10; ram[iReg] = (c / 100) % 10; } break; @@ -313,7 +313,7 @@ void Chip8::Update() case 0x55: { // LD [I], Vx - for (int i = 0; i <= x; i++) ram[iReg + i] = regs[i]; + for (int i = 0; i <= x; i++) ram[(iReg + i) & 0xfff] = regs[i]; iReg = (iReg + x + 1) & 0xfff; } break; @@ -321,7 +321,7 @@ void Chip8::Update() case 0x65: { // LD Vx, [I] - for (int i = 0; i <= x; i++) regs[i] = ram[iReg + i]; + for (int i = 0; i <= x; i++) regs[i] = ram[(iReg + i) & 0xfff]; iReg = (iReg + x + 1) & 0xfff; } break; diff --git a/Main.cpp b/Main.cpp index fe2fc2d..c3fc602 100644 --- a/Main.cpp +++ b/Main.cpp @@ -60,7 +60,6 @@ int Main(const List& arguments) auto fileLoadRomImage = MenuItem::Create("Load ROM Image..."); fileLoadRomImage->Click += [&] { - // TODO: File filters auto fileName = DialogWindow::OpenFile(window, "Load ROM Image"); if (fileName.Length()) { @@ -190,7 +189,7 @@ int Main(const List& arguments) auto videoDriver = new GLVideoDriver(viewport); chip8.SetVideoDriver(videoDriver); - if (arguments.Count()) loadAndStartRomImage(arguments[0]); // TODO: proper arg's + if (arguments.Count()) loadAndStartRomImage(arguments[0]); while (running) {