Compare commits

...

4 Commits

Author SHA1 Message Date
iris 7d706e703f sdf 2026-05-19 08:48:58 +02:00
iris 03a6a9b383 ok imma stop using size_t at this point 2026-05-19 08:48:52 +02:00
iris 8d6d6c0672 Merge commit 'a8099e3aeafb464445d1c3ee3a852697d37a1e69' 2026-05-19 08:43:09 +02:00
iris a8099e3aea Squashed 'external/ircolib/' changes from 7df4ec224..bb3f168e1
bb3f168e1 fix compilation on windows

git-subtree-dir: external/ircolib
git-subtree-split: bb3f168e134aee5dd5460e57b43d06ef84a06092
2026-05-19 08:43:08 +02:00
6 changed files with 28 additions and 7 deletions
+5 -2
View File
@@ -147,6 +147,9 @@ void broadway::execute(ircolib::u32 instr, mem &mem) {
case 33:
lwzu(instr, mem);
break;
case 34:
lbz(instr, mem);
break;
case 36:
stw(instr, mem);
break;
@@ -179,11 +182,11 @@ void broadway::print_disasm(ircolib::u32 instr) {
cs_insn *insn;
auto instr_buff = ircolib::integral_to_slice(std::byteswap(instr));
size_t count = cs_disasm(capstone, instr_buff.data(), instr_buff.size(), pc - 4, 1, &insn);
ircolib::u32 count = cs_disasm(capstone, instr_buff.data(), instr_buff.size(), pc - 4, 1, &insn);
if (count <= 0)
return;
size_t j;
ircolib::u32 j;
for (j = 0; j < count; j++) {
std::println("\t0x{:x}:\t{}\t\t{}", insn[j].address, insn[j].mnemonic, insn[j].op_str);
}
+3 -2
View File
@@ -38,8 +38,8 @@ struct broadway {
bool get_cr_bit(ircolib::u8 index, ircolib::u8 bit) { return (cr >> index * 4) & (1 << (4 - bit)); }
// bat registers indexes
static constexpr std::size_t BAT_LOWER_OFFSET = 0;
static constexpr std::size_t BAT_UPPER_OFFSET = 8;
static constexpr ircolib::u32 BAT_LOWER_OFFSET = 0;
static constexpr ircolib::u32 BAT_UPPER_OFFSET = 8;
std::array<ircolib::u32, 16> ibat, dbat;
std::array<ircolib::u32, 32> gpr{};
@@ -75,6 +75,7 @@ struct broadway {
void stwu(ircolib::u32, mem &);
void stbu(ircolib::u32, mem &);
void sth(ircolib::u32, mem &);
void lbz(ircolib::u32, mem &);
void lwz(ircolib::u32, mem &);
void lfd(ircolib::u32, mem &);
void bclrx(ircolib::u32);
+17 -1
View File
@@ -70,7 +70,7 @@ void broadway::bcx(ircolib::u32 instr) {
}
void broadway::mftspr(bool dir, ircolib::u32 instr) {
const size_t spr_field = (instr >> 11) & 0x3FF;
const ircolib::u32 spr_field = (instr >> 11) & 0x3FF;
auto move_to_or_from_spr = [&](ircolib::u32 &spr) {
if (dir) { // mtspr
@@ -219,6 +219,22 @@ void broadway::lwz(ircolib::u32 instr, mem &mem) {
.value();
}
void broadway::lbz(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.read8(ea)
.and_then([&](ircolib::u32 val) { return std::expected<ircolib::u32, std::string>(val); })
.or_else([&](std::string e) {
ircolib::panic("broadway read failed. Reason {} (pc: 0x{:08X})", e, pc - 4);
return std::expected<ircolib::u32, std::string>();
})
.value();
}
void broadway::lfd(ircolib::u32 instr, mem &mem) {
ircolib::u32 b = gpr[utils::RA(instr)];
if (utils::RA(instr) == 0)
+1 -1
View File
@@ -20,7 +20,7 @@ bool load_dol(const std::string &path, mem &mem, broadway &broadway) {
ircolib::u32 bss_address, bss_size, entry_point;
} hdr;
for (size_t bin_index = 0; bin_index < 0xD8; bin_index += 4) {
for (ircolib::u32 bin_index = 0; bin_index < 0xD8; bin_index += 4) {
if (ircolib::is_inside_range(bin_index, 0, 0x1b)) // text file offsets
hdr.text[bin_index / 4].offset = std::byteswap(ircolib::read_access<ircolib::u32>(bin, bin_index));
+1 -1
View File
@@ -10,7 +10,7 @@ bool load_elf(const std::string &path, mem &mem, broadway &broadway) {
if (!reader.load(path))
return false;
size_t sanity_bss_check_count = 0;
ircolib::u32 sanity_bss_check_count = 0;
for (const auto &segment : reader.segments) {
const auto segment_type = segment->get_type();
+1
View File
@@ -1,5 +1,6 @@
#pragma once
#include <cstdint>
#include <cstddef>
namespace ircolib {
using u8 = uint8_t;