aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/teakra/src/btdmp.cpp5
-rw-r--r--src/teakra/src/btdmp.h5
-rw-r--r--src/teakra/src/dma.h5
-rw-r--r--src/teakra/src/interpreter.h25
-rw-r--r--src/teakra/src/mmio.cpp2
5 files changed, 34 insertions, 8 deletions
diff --git a/src/teakra/src/btdmp.cpp b/src/teakra/src/btdmp.cpp
index 20a1f09..abdaf52 100644
--- a/src/teakra/src/btdmp.cpp
+++ b/src/teakra/src/btdmp.cpp
@@ -28,16 +28,15 @@ void Btdmp::Tick() {
std::array<std::int16_t, 2> sample;
for (int i = 0; i < 2; ++i) {
if (transmit_queue.empty()) {
- std::printf("BTDMP: transmit buffer underrun\n");
+ //std::printf("BTDMP: transmit buffer underrun\n");
sample[i] = 0;
} else {
sample[i] = static_cast<s16>(transmit_queue.front());
transmit_queue.pop();
transmit_empty = transmit_queue.empty();
transmit_full = false;
- if (transmit_empty) {
+ if (transmit_empty)
interrupt_handler();
- }
}
}
if (audio_callback) {
diff --git a/src/teakra/src/btdmp.h b/src/teakra/src/btdmp.h
index 63cbb9b..da0a932 100644
--- a/src/teakra/src/btdmp.h
+++ b/src/teakra/src/btdmp.h
@@ -58,6 +58,11 @@ public:
}
}
+ u16 Receive() {
+ printf("BTDMP RECEIVE TODO!!\n");
+ return 0;
+ }
+
void SetTransmitFlush(u16 value) {
transmit_queue = {};
transmit_empty = true;
diff --git a/src/teakra/src/dma.h b/src/teakra/src/dma.h
index f5a8112..6aa05c2 100644
--- a/src/teakra/src/dma.h
+++ b/src/teakra/src/dma.h
@@ -16,6 +16,11 @@ public:
void Reset();
void EnableChannel(u16 value) {
+ u16 chk = value & ~enable_channel;
+ for (int i = 0; i < 8; i++) {
+ if (chk & (1<<i))
+ DoDma(i);
+ }
enable_channel = value;
}
u16 GetChannelEnabled() const {
diff --git a/src/teakra/src/interpreter.h b/src/teakra/src/interpreter.h
index aac4916..98241a3 100644
--- a/src/teakra/src/interpreter.h
+++ b/src/teakra/src/interpreter.h
@@ -19,6 +19,7 @@ namespace Teakra {
class UnimplementedException : public std::runtime_error {
public:
UnimplementedException() : std::runtime_error("unimplemented") {}
+ UnimplementedException(const char* err) : std::runtime_error(err) {}
};
class Interpreter {
@@ -261,7 +262,7 @@ public:
SatAndSetAccAndFlag(d1, v); // only this one affects flags (except for fl)
}
void trap() {
- throw UnimplementedException();
+ throw UnimplementedException("trap");
}
void DoMultiplication(u32 unit, bool x_sign, bool y_sign) {
@@ -448,7 +449,7 @@ public:
AlmOp::Or, AlmOp::And, AlmOp::Xor, AlmOp::Add, AlmOp::Cmp, AlmOp::Sub,
};
if (allowed_instruction.count(op.GetName()) == 0)
- throw UnimplementedException(); // weird effect. probably undefined
+ throw UnimplementedException("weird alm"); // weird effect. probably undefined
};
switch (a.GetName()) {
// need more test
@@ -600,7 +601,7 @@ public:
if (b.GetName() == RegName::p) {
bv = (u16)(ProductToBus40(Px{0}) >> 16);
} else if (b.GetName() == RegName::a0 || b.GetName() == RegName::a1) {
- throw UnimplementedException(); // weird effect;
+ throw UnimplementedException("weird alb"); // weird effect;
} else {
bv = RegToBus16(b.GetName());
}
@@ -1180,7 +1181,21 @@ public:
}
}
void retd() {
- throw UnimplementedException();
+ // TODO: this is grossly inaccurate
+ // retd is supposed to kick in after 2 cycles
+
+ for (int i = 0; i < 2; i++) {
+ u16 opcode = mem.ProgramRead((regs.pc++) | (regs.prpage << 18));
+ auto& decoder = decoders[opcode];
+ u16 expand_value = 0;
+ if (decoder.NeedExpansion()) {
+ expand_value = mem.ProgramRead((regs.pc++) | (regs.prpage << 18));
+ }
+
+ decoder.call(*this, opcode, expand_value);
+ }
+
+ PopPC();
}
void reti(Cond c) {
if (regs.ConditionPass(c)) {
@@ -3430,7 +3445,7 @@ private:
} else { // OffsetValue::MinusOne
if (!emod)
return address - 1;
- throw UnimplementedException();
+ //throw UnimplementedException("weird OffsetAddress");
// TODO: sometimes this would return two addresses,
// neither of which is the original Rn value.
// This only happens for memory writing, but not for memory reading.
diff --git a/src/teakra/src/mmio.cpp b/src/teakra/src/mmio.cpp
index 0a8e3bc..9834758 100644
--- a/src/teakra/src/mmio.cpp
+++ b/src/teakra/src/mmio.cpp
@@ -344,6 +344,7 @@ MMIORegion::MMIORegion(MemoryInterfaceUnit& miu, ICU& icu, Apbp& apbp_from_cpu,
BitFieldSlot{4, 1, {}, std::bind(&Btdmp::GetTransmitEmpty, &btdmp[i])},
});
impl->cells[0x2C6 + i * 0x80].set = std::bind(&Btdmp::Send, &btdmp[i], _1);
+ impl->cells[0x2C6 + i * 0x80].get = std::bind(&Btdmp::Receive, &btdmp[i]);
impl->cells[0x2CA + i * 0x80].set = std::bind(&Btdmp::SetTransmitFlush, &btdmp[i], _1);
impl->cells[0x2CA + i * 0x80].get = std::bind(&Btdmp::GetTransmitFlush, &btdmp[i]);
}
@@ -355,6 +356,7 @@ u16 MMIORegion::Read(u16 addr) {
u16 value = impl->cells[addr].get();
return value;
}
+
void MMIORegion::Write(u16 addr, u16 value) {
impl->cells[addr].set(value);
}