From 44ff68d6f3caf9ef4709e0143c3d20e849fe39d4 Mon Sep 17 00:00:00 2001 From: Adrian Conlon Date: Mon, 2 Oct 2017 16:47:05 +0100 Subject: [PATCH] First part of gb linux port. Signed-off-by: Adrian Conlon --- LR35902/inc/GameBoyBus.h | 2 +- LR35902/inc/LR35902.h | 12 +++++----- LR35902/src/Disassembler.cpp | 2 +- LR35902/src/GameBoyBus.cpp | 2 +- LR35902/src/LR35902.cpp | 44 ++++++++++++++++++------------------ LR35902/src/stdafx.h | 2 ++ 6 files changed, 33 insertions(+), 31 deletions(-) diff --git a/LR35902/inc/GameBoyBus.h b/LR35902/inc/GameBoyBus.h index 3d9b147..147c0e7 100644 --- a/LR35902/inc/GameBoyBus.h +++ b/LR35902/inc/GameBoyBus.h @@ -159,7 +159,7 @@ namespace EightBit { case 0b11: return 256; // 16.384 Khz default: - __assume(0); + UNREACHABLE; } throw std::domain_error("Invalid timer clock specification"); } diff --git a/LR35902/inc/LR35902.h b/LR35902/inc/LR35902.h index 88af7e0..6059d07 100644 --- a/LR35902/inc/LR35902.h +++ b/LR35902/inc/LR35902.h @@ -120,8 +120,8 @@ namespace EightBit { } register16_t& RP(int rp) { - __assume(rp < 4); - __assume(rp >= 0); + assert(rp < 4); + assert(rp >= 0); switch (rp) { case 0b00: return BC(); @@ -132,13 +132,13 @@ namespace EightBit { case 0b11: return SP(); default: - __assume(0); + UNREACHABLE; } } register16_t& RP2(int rp) { - __assume(rp < 4); - __assume(rp >= 0); + assert(rp < 4); + assert(rp >= 0); switch (rp) { case 0b00: return BC(); @@ -149,7 +149,7 @@ namespace EightBit { case 0b11: return AF(); default: - __assume(0); + UNREACHABLE; } } diff --git a/LR35902/src/Disassembler.cpp b/LR35902/src/Disassembler.cpp index 8e869f1..e3d9fb1 100644 --- a/LR35902/src/Disassembler.cpp +++ b/LR35902/src/Disassembler.cpp @@ -202,7 +202,7 @@ void EightBit::GameBoy::Disassembler::disassemble(std::ostringstream& output, LR case Unused: break; default: - __assume(0); + UNREACHABLE; } } diff --git a/LR35902/src/GameBoyBus.cpp b/LR35902/src/GameBoyBus.cpp index 02eff55..82ee076 100644 --- a/LR35902/src/GameBoyBus.cpp +++ b/LR35902/src/GameBoyBus.cpp @@ -173,7 +173,7 @@ void EightBit::GameBoy::Bus::Bus_WrittenByte(const uint16_t address) { m_ramBankSwitching = true; break; default: - __assume(0); + UNREACHABLE; } handled = true; } diff --git a/LR35902/src/LR35902.cpp b/LR35902/src/LR35902.cpp index b9b5a3d..145ced5 100644 --- a/LR35902/src/LR35902.cpp +++ b/LR35902/src/LR35902.cpp @@ -70,7 +70,7 @@ bool EightBit::GameBoy::LR35902::jrConditionalFlag(uint8_t& f, int flag) { case 3: // C return jrConditional(f & CF); default: - __assume(0); + UNREACHABLE; } throw std::logic_error("Unhandled JR conditional"); } @@ -86,7 +86,7 @@ bool EightBit::GameBoy::LR35902::jumpConditionalFlag(uint8_t& f, int flag) { case 3: // C return jumpConditional(f & CF); default: - __assume(0); + UNREACHABLE; } throw std::logic_error("Unhandled JP conditional"); } @@ -107,7 +107,7 @@ bool EightBit::GameBoy::LR35902::returnConditionalFlag(uint8_t& f, int flag) { case 3: // C return returnConditional(f & CF); default: - __assume(0); + UNREACHABLE; } throw std::logic_error("Unhandled RET conditional"); } @@ -123,7 +123,7 @@ bool EightBit::GameBoy::LR35902::callConditionalFlag(uint8_t& f, int flag) { case 3: // C return callConditional(f & CF); default: - __assume(0); + UNREACHABLE; } throw std::logic_error("Unhandled CALL conditional"); } @@ -536,7 +536,7 @@ void EightBit::GameBoy::LR35902::executeCB(int x, int y, int z, int p, int q) { operand = srl(f, operand); break; default: - __assume(0); + UNREACHABLE; } cycles += 2; R(z, a, operand); @@ -563,7 +563,7 @@ void EightBit::GameBoy::LR35902::executeCB(int x, int y, int z, int p, int q) { cycles += 2; break; default: - __assume(0); + UNREACHABLE; } } @@ -600,7 +600,7 @@ void EightBit::GameBoy::LR35902::executeOther(int x, int y, int z, int p, int q) cycles += 2; break; default: - __assume(0); + UNREACHABLE; } break; case 1: // 16-bit load immediate/add @@ -614,7 +614,7 @@ void EightBit::GameBoy::LR35902::executeOther(int x, int y, int z, int p, int q) cycles += 2; break; default: - __assume(0); + UNREACHABLE; } break; case 2: // Indirect loading @@ -638,7 +638,7 @@ void EightBit::GameBoy::LR35902::executeOther(int x, int y, int z, int p, int q) cycles += 2; break; default: - __assume(0); + UNREACHABLE; } break; case 1: @@ -660,11 +660,11 @@ void EightBit::GameBoy::LR35902::executeOther(int x, int y, int z, int p, int q) cycles += 2; break; default: - __assume(0); + UNREACHABLE; } break; default: - __assume(0); + UNREACHABLE; } break; case 3: // 16-bit INC/DEC @@ -676,7 +676,7 @@ void EightBit::GameBoy::LR35902::executeOther(int x, int y, int z, int p, int q) --RP(p).word; break; default: - __assume(0); + UNREACHABLE; } cycles += 2; break; @@ -727,12 +727,12 @@ void EightBit::GameBoy::LR35902::executeOther(int x, int y, int z, int p, int q) ccf(a, f); break; default: - __assume(0); + UNREACHABLE; } cycles++; break; default: - __assume(0); + UNREACHABLE; } break; case 1: // 8-bit loading @@ -772,7 +772,7 @@ void EightBit::GameBoy::LR35902::executeOther(int x, int y, int z, int p, int q) compare(f, a, R(z, a)); break; default: - __assume(0); + UNREACHABLE; } cycles++; if (z == 6) @@ -823,7 +823,7 @@ void EightBit::GameBoy::LR35902::executeOther(int x, int y, int z, int p, int q) cycles += 3; break; default: - __assume(0); + UNREACHABLE; } break; case 1: // POP & various ops @@ -851,11 +851,11 @@ void EightBit::GameBoy::LR35902::executeOther(int x, int y, int z, int p, int q) cycles += 2; break; default: - __assume(0); + UNREACHABLE; } break; default: - __assume(0); + UNREACHABLE; } break; case 2: // Conditional jump @@ -886,7 +886,7 @@ void EightBit::GameBoy::LR35902::executeOther(int x, int y, int z, int p, int q) cycles += 4; break; default: - __assume(0); + UNREACHABLE; } break; case 3: // Assorted operations @@ -931,7 +931,7 @@ void EightBit::GameBoy::LR35902::executeOther(int x, int y, int z, int p, int q) } break; default: - __assume(0); + UNREACHABLE; } break; case 6: // Operate on accumulator and immediate operand: alu[y] n @@ -961,7 +961,7 @@ void EightBit::GameBoy::LR35902::executeOther(int x, int y, int z, int p, int q) compare(f, a, fetchByte()); break; default: - __assume(0); + UNREACHABLE; } cycles += 2; break; @@ -970,7 +970,7 @@ void EightBit::GameBoy::LR35902::executeOther(int x, int y, int z, int p, int q) cycles += 4; break; default: - __assume(0); + UNREACHABLE; } break; } diff --git a/LR35902/src/stdafx.h b/LR35902/src/stdafx.h index 83e44c1..01a1c3a 100644 --- a/LR35902/src/stdafx.h +++ b/LR35902/src/stdafx.h @@ -1,4 +1,6 @@ +#ifdef _MSC_VER #pragma once +#endif #include #include