getting closer and closer to the xfb copy loop in panda

This commit is contained in:
2026-05-13 11:27:28 +02:00
parent fc26f75118
commit 9c3a6789f6
9 changed files with 319 additions and 82 deletions
+21 -4
View File
@@ -118,12 +118,20 @@ void broadway::stwu(ircolib::u32 instr, mem &mem) {
if (utils::RA(instr) == 0)
ircolib::panic("broadway::stwu with ra == 0");
const ircolib::s32 d = utils::SIMM(instr);
const ircolib::u32 EA = gpr[utils::RA(instr)] + d;
mem.write(EA, gpr[utils::RS(instr)]);
const ircolib::u32 EA = ircolib::s32(gpr[utils::RA(instr)]) + utils::SIMM(instr);
mem.write32(EA, gpr[utils::RS(instr)]);
gpr[utils::RA(instr)] = EA;
}
void broadway::stw(ircolib::u32 instr, mem &mem) {
ircolib::s32 b = gpr[utils::RA(instr)];
if (utils::RA(instr) == 0)
b = 0;
const ircolib::u32 EA = b + utils::SIMM(instr);
mem.write32(EA, gpr[utils::RS(instr)]);
}
void broadway::sth(ircolib::u32 instr, mem &mem) {
ircolib::u32 b = gpr[utils::RA(instr)];
if (utils::RA(instr) == 0)
@@ -132,6 +140,15 @@ void broadway::sth(ircolib::u32 instr, mem &mem) {
const ircolib::s32 d = utils::SIMM(instr);
const ircolib::u32 EA = b + d;
mem.write(EA, ircolib::u16(gpr[utils::RS(instr)]));
mem.write16(EA, ircolib::u16(gpr[utils::RS(instr)]));
}
void broadway::lwz(ircolib::u32 instr, mem &mem) {
ircolib::u32 b = gpr[utils::RA(instr)];
if (utils::RA(instr) == 0)
b = 0;
ircolib::u32 ea = ircolib::s32(b) + utils::SIMM(instr);
gpr[utils::RD(instr)] = mem.read32(ea);
}
} // namespace weee::core
+43 -5
View File
@@ -1,15 +1,53 @@
#include <broadway/mmio/vi.hpp>
#include "ircolib/log.hpp"
#include <ircolib/log.hpp>
#include <mem.hpp>
namespace weee::core {
void video_interface::write(ircolib::u32 addr, ircolib::u16 value) {
addr -= 0x0c002000;
video_interface::video_interface(mem &mem) {
mem.register_write16_handler(0x0c002000, 0x0c0020ff,
[&](ircolib::u32 addr, ircolib::u16 value) { write16(addr, value); });
mem.register_write32_handler(0x0c002000, 0x0c0020ff,
[&](ircolib::u32 addr, ircolib::u32 value) { write32(addr, value); });
}
void video_interface::write16(ircolib::u32 addr, ircolib::u16 value) {
switch (addr) {
case 2:
case 0x00:
vtr.raw = value;
break;
case 0x02:
dcr.raw = value;
break;
default:
ircolib::panic("video_interface::write to unimplemented addr 0x{:04X} with value 0x{:04X}", addr, value);
ircolib::panic("video_interface::write16 to unimplemented addr 0x{:04X} with value 0x{:04X}", addr, value);
}
}
void video_interface::write32(ircolib::u32 addr, ircolib::u32 value) {
switch (addr) {
case 0x02:
dcr.raw = value;
break;
case 0x04:
htr0.raw = value;
break;
case 0x08:
htr1.raw = value;
break;
case 0x0c:
vto.raw = value;
break;
case 0x10:
vte.raw = value;
break;
case 0x14:
bbei.raw = value;
break;
case 0x18:
bboi.raw = value;
break;
default:
ircolib::panic("video_interface::write32 to unimplemented addr 0x{:04X} with value 0x{:08X}", addr, value);
}
}
} // namespace weee::core
+74 -17
View File
@@ -2,25 +2,82 @@
#include <ircolib/types.hpp>
namespace weee::core {
union DCR {
struct {
unsigned e : 1;
unsigned r : 1;
unsigned i : 1;
unsigned d : 1;
unsigned le0 : 2;
unsigned le1 : 2;
unsigned fmt : 2;
unsigned : 6;
};
ircolib::u16 raw;
};
struct mem;
struct video_interface {
void write(ircolib::u32, ircolib::u16);
video_interface(mem &);
void write16(ircolib::u32, ircolib::u16);
void write32(ircolib::u32, ircolib::u32);
private:
DCR dcr{};
union DCR {
struct {
unsigned e : 1;
unsigned r : 1;
unsigned i : 1;
unsigned d : 1;
unsigned le0 : 2;
unsigned le1 : 2;
unsigned fmt : 2;
unsigned : 6;
};
ircolib::u16 raw;
} dcr;
union HTR0 {
struct {
unsigned hlw : 9;
unsigned : 7;
unsigned hce : 7;
unsigned : 1;
unsigned hcs : 7;
unsigned : 1;
};
ircolib::u32 raw;
} htr0;
union HTR1 {
struct {
unsigned hsy : 7;
unsigned hbe : 10;
unsigned hbs : 10;
unsigned : 5;
};
ircolib::u32 raw;
} htr1;
union VTR {
struct {
unsigned equ : 4;
unsigned acv : 10;
unsigned : 2;
};
ircolib::u16 raw;
} vtr;
union VTO {
struct {
unsigned prb : 10;
unsigned : 6;
unsigned psb : 10;
unsigned : 6;
};
ircolib::u32 raw;
} vto, vte;
union BBI {
struct {
unsigned bs1 : 5;
unsigned be1 : 11;
unsigned bs3 : 5;
unsigned be3 : 11;
};
ircolib::u32 raw;
} bbei, bboi;
};
} // namespace weee::core