more fun DSP fixes

* aac.a thinks it is funny to start DMA by writing to 8184 directly
* implement retd (gross hack!!)
* remove another unimplemented exception (wat)
This commit is contained in:
Arisotura 2022-10-17 20:16:19 +02:00
parent 243a02767a
commit 31ba585d39
5 changed files with 34 additions and 8 deletions

View File

@ -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) {

View File

@ -58,6 +58,11 @@ public:
}
}
u16 Receive() {
printf("BTDMP RECEIVE TODO!!\n");
return 0;
}
void SetTransmitFlush(u16 value) {
transmit_queue = {};
transmit_empty = true;

View File

@ -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 {

View File

@ -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.

View File

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