First part of gb linux port.

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2017-10-02 16:47:05 +01:00
parent c06c0d2cf9
commit 44ff68d6f3
6 changed files with 33 additions and 31 deletions

View File

@ -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");
}

View File

@ -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;
}
}

View File

@ -202,7 +202,7 @@ void EightBit::GameBoy::Disassembler::disassemble(std::ostringstream& output, LR
case Unused:
break;
default:
__assume(0);
UNREACHABLE;
}
}

View File

@ -173,7 +173,7 @@ void EightBit::GameBoy::Bus::Bus_WrittenByte(const uint16_t address) {
m_ramBankSwitching = true;
break;
default:
__assume(0);
UNREACHABLE;
}
handled = true;
}

View File

@ -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;
}

View File

@ -1,4 +1,6 @@
#ifdef _MSC_VER
#pragma once
#endif
#include <cstdint>
#include <stdexcept>