Compare commits

...

14 Commits

Author SHA1 Message Date
iris 2f0c837464 cool 2026-05-19 00:11:48 +02:00
iris f375b9c0ee Merge commit 'e26567772789c28c79920624e1622a7a3306c560' 2026-05-19 00:06:03 +02:00
iris e265677727 Squashed 'external/ircolib/' changes from ec06dab..7df4ec2
7df4ec2 clear bit

git-subtree-dir: external/ircolib
git-subtree-split: 7df4ec22463394c2763fef61b581b3d2980778ef
2026-05-19 00:06:03 +02:00
iris 59b6c70c3f booogs 2026-05-19 00:04:56 +02:00
iris 0754d52d67 Squashed 'external/ircolib/' changes from cf68f4c..ec06dab
ec06dab logging

git-subtree-dir: external/ircolib
git-subtree-split: ec06dab96452fb0d3b4c93e71dbdf9869e39f7e5
2026-05-18 23:29:31 +02:00
iris b50e0a529d Merge commit '0754d52d67766f39276ae32771bca3f28b1ac3dc' 2026-05-18 23:29:31 +02:00
iris 74b13b4d70 Squashed 'external/ircolib/' changes from 8cb69c8..cf68f4c
cf68f4c improvements

git-subtree-dir: external/ircolib
git-subtree-split: cf68f4c385c6f2def0e359c3c2a7621ce78062a8
2026-05-18 23:28:07 +02:00
iris 8c0b0bfc1b Merge commit '74b13b4d7049f9181b1241195324e85af2d9653a' 2026-05-18 23:28:07 +02:00
iris 5024d45e58 Squashed 'external/ircolib/' changes from ce3cd72..8cb69c8
8cb69c8 Merge commit '634f6ff006c8811c47a7a07356f46214f5d8a736' as 'external/ircolib'
2230d4c dhjkfhsdf
c2e22fb better logs
eee9fcf there might be an off by 1 error...
aeb5094 getting floating point stuff now
b13161f Branches simplified, and working!
e48f6a6 trying to simplify branches
b2f415a start crediting people <3
723e668 rfi
9a2d437 oris
7c456e5 rendering Panda correctly
df6f382 Merge commit '4870214d575293257604fa75a6458f0f0a7ea083' as 'external/yuv2rgb'
4870214 Squashed 'external/yuv2rgb/' content from commit ee78934c8
8bd3935 YUV
9df9eda almost rendering correctly
c8d2b36 Merge commit '411251c6242b04119edc41ce83f09f0714e2d32b' as 'external/SDL'
411251c Squashed 'external/SDL/' content from commit 716c767b7
d057a31 xfb loop copy finished
9c3a678 getting closer and closer to the xfb copy loop in panda
fc26f75 bcx partially implemented
df68e42 getting conditional branch now
2be9570 getting to my first branch now
e598f02 Merge commit '2201a0227297b9251717e44adc32554a51ca0ed6' as 'external/xbyak'
2201a02 Squashed 'external/xbyak/' content from commit 431abd86
fc5beeb start executing
0b1d14b loading dols
5f1e3aa asdfasfd
be41857 todo list in readme
93cab1e we load the ELF correctly it seems!
831e03e Merge commit '884e597e3572c5a47c15270649c1e0c24fae3a18' as 'external/cflags'
884e597 Squashed 'external/cflags/' content from commit cc3ea1b
cc2dfc0 do not care about sections as hazel teaches
2b01767 cool
f563827 Merge commit '44fea07a8bae832d53bfdcec3b4cfbf0b60f987d' as 'external/ircolib'
44fea07 Squashed 'external/ircolib/' content from commit ce3cd726
1803ee7 ok
e5413f9 introduce capstone
c0de074 Merge commit '802798ce3c8baa4697120580f87bc1ee377306d3' as 'external/capstone'
802798c Squashed 'external/capstone/' content from commit e46f64fa
ef8e742 read ELF
fede961 Merge commit 'a67f311330461cf90801a74fe351a4a80a5abb11' as 'external/ELFIO'
a67f311 Squashed 'external/ELFIO/' content from commit 94f7706
ad83dec gitignore
9130ede first commit

git-subtree-dir: external/ircolib
git-subtree-split: 8cb69c875cb5e3e3a8f18204ed88ea73de456df6
2026-05-18 23:22:33 +02:00
iris 83e3f5423f Merge commit '5024d45e589ebd708e2d5091632197235a1b1e23' 2026-05-18 23:22:33 +02:00
iris bb54f0c15b sadfasdf 2026-05-18 23:22:30 +02:00
iris 634f6ff006 Squashed 'external/ircolib/' content from commit ce3cd72
git-subtree-dir: external/ircolib
git-subtree-split: ce3cd726c8df8388d554abf8bb55d55020eb4450
2026-05-18 23:13:51 +02:00
iris f72110272d Merge commit '634f6ff006c8811c47a7a07356f46214f5d8a736' as 'external/ircolib' 2026-05-18 23:13:51 +02:00
iris 2230d4c662 dhjkfhsdf 2026-05-18 23:13:35 +02:00
8 changed files with 117 additions and 39 deletions
+1 -1
View File
@@ -169,7 +169,7 @@ void broadway::execute(ircolib::u32 instr, mem &mem) {
std::println("broadway::execute unimplemented instruction 0x{:08X} / 0b{:032b}", instr, instr);
std::println("disassembly:");
print_disasm(instr);
ircolib::panic("");
ircolib::panic("LR: 0x{:08X}", lr);
}
}
+34 -18
View File
@@ -3,10 +3,13 @@
#include <mem.hpp>
namespace weee::core {
void broadway::add(ircolib::u32 instr) { gpr[utils::RD(instr)] = gpr[utils::RA(instr)] + gpr[utils::RB(instr)]; }
void broadway::add(ircolib::u32 instr) {
gpr[utils::RD(instr)] = gpr[utils::RA(instr)] + gpr[utils::RB(instr)];
cr0_update(instr & 1, gpr[utils::RD(instr)]);
}
void broadway::addi(ircolib::u32 instr) {
if (utils::RA(instr) == 0) { // lis
if (utils::RA(instr) == 0) { // li
gpr[utils::RD(instr)] = ircolib::s32(utils::SIMM(instr));
return;
}
@@ -145,12 +148,14 @@ void broadway::stwu(ircolib::u32 instr, mem &mem) {
const ircolib::u32 EA = ircolib::s32(gpr[utils::RA(instr)]) + utils::SIMM(instr);
auto _ = mem.write32(EA, gpr[utils::RS(instr)])
.and_then([&] { return std::expected<void, std::string>(); })
.and_then([&] {
gpr[utils::RA(instr)] = EA;
return std::expected<void, std::string>();
})
.or_else([&](std::string e) {
ircolib::panic("stwu broadway write failed. Reason: {} (pc: 0x{:08X})", e, pc - 4);
return std::expected<void, std::string>();
});
gpr[utils::RA(instr)] = EA;
}
void broadway::stbu(ircolib::u32 instr, mem &mem) {
@@ -159,12 +164,14 @@ void broadway::stbu(ircolib::u32 instr, mem &mem) {
const ircolib::u32 EA = ircolib::s32(gpr[utils::RA(instr)]) + utils::SIMM(instr);
auto _ = mem.write8(EA, gpr[utils::RS(instr)])
.and_then([&] { return std::expected<void, std::string>(); })
.and_then([&] {
gpr[utils::RA(instr)] = EA;
return std::expected<void, std::string>();
})
.or_else([&](std::string e) {
ircolib::panic("stbu broadway write failed. Reason: {} (pc: 0x{:08X})", e, pc - 4);
return std::expected<void, std::string>();
});
gpr[utils::RA(instr)] = EA;
}
void broadway::stw(ircolib::u32 instr, mem &mem) {
@@ -186,8 +193,7 @@ void broadway::sth(ircolib::u32 instr, mem &mem) {
if (utils::RA(instr) == 0)
b = 0;
const ircolib::s32 d = utils::SIMM(instr);
const ircolib::u32 EA = b + d;
const ircolib::u32 EA = b + utils::SIMM(instr);
auto _ = mem.write16(EA, ircolib::u16(gpr[utils::RS(instr)]))
.and_then([&] { return std::expected<void, std::string>(); })
@@ -219,16 +225,15 @@ void broadway::lfd(ircolib::u32 instr, mem &mem) {
b = 0;
ircolib::u32 ea = ircolib::s32(b) + utils::SIMM(instr);
double val;
ircolib::u64 read = mem.read64(ea)
fgrs[utils::RD(instr)].ps0 =
mem.read64(ea)
.and_then([&](ircolib::u64 val) { return std::expected<ircolib::u64, std::string>(val); })
.or_else([&](std::string e) {
ircolib::panic("broadway read failed. Reason {} (pc: 0x{:08X})", e, pc - 4);
return std::expected<ircolib::u64, std::string>();
})
.value();
memcpy(&val, &read, 8);
fgrs[utils::RD(instr)].ps0 = val;
}
void broadway::bclrx(ircolib::u32 instr) {
@@ -305,9 +310,15 @@ void broadway::rlwinm(ircolib::u32 instr) {
ircolib::u32 r = std::rotl(gpr[utils::RS(instr)], sh);
const ircolib::u8 mb = (instr >> 6) & 0x1f;
const ircolib::u8 me = (instr >> 1) & 0x1f;
const ircolib::u32 start = 0xffffffff >> mb;
const ircolib::u32 end = 0x7fffffff >> me;
ircolib::u32 mask = start ^ end;
if (mb > me)
mask = ~mask;
r &= ~((0xFFFF'FFFF >> mb) << me);
r &= mask;
gpr[utils::RA(instr)] = r;
cr0_update(instr & 1, r);
}
void broadway::lwzu(ircolib::u32 instr, mem &mem) {
@@ -316,16 +327,21 @@ void broadway::lwzu(ircolib::u32 instr, mem &mem) {
const ircolib::u32 EA = ircolib::s32(gpr[utils::RA(instr)]) + utils::SIMM(instr);
gpr[utils::RD(instr)] = mem.read32(EA)
.and_then([&](ircolib::u32 val) { return std::expected<ircolib::u32, std::string>(val); })
.and_then([&](ircolib::u32 val) {
gpr[utils::RA(instr)] = EA;
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();
gpr[utils::RA(instr)] = EA;
}
void broadway::rfi(ircolib::u32 instr) { pc = srr0; }
void broadway::rfi(ircolib::u32 instr) {
pc = srr0;
ircolib::clear_bit(msr, 13);
}
void broadway::andi(ircolib::u32 instr) {
const ircolib::s32 result = gpr[utils::RS(instr)] & utils::UIMM(instr);
@@ -370,12 +386,12 @@ void broadway::nand(ircolib::u32 instr) {
}
void broadway::subf(ircolib::u32 instr) {
gpr[utils::RD(instr)] = ~(gpr[utils::RA(instr)] + gpr[utils::RB(instr)] + 1);
gpr[utils::RD(instr)] = ~gpr[utils::RA(instr)] + gpr[utils::RB(instr)];
cr0_update(instr & 1, gpr[utils::RD(instr)]);
}
void broadway:: or (ircolib::u32 instr) {
gpr[utils::RA(instr)] = gpr[utils::RS(instr)] & gpr[utils::RB(instr)];
gpr[utils::RA(instr)] = gpr[utils::RS(instr)] | gpr[utils::RB(instr)];
cr0_update(instr & 1, gpr[utils::RA(instr)]);
}
} // namespace weee::core
+1 -1
View File
@@ -1,7 +1,7 @@
#include <cstring>
#include <mem.hpp>
#include <ircolib/log.hpp>
#include "ircolib/mem_access.hpp"
#include <ircolib/mem_access.hpp>
namespace weee::core {
mem::mem() : vi(*this) {
+56
View File
@@ -0,0 +1,56 @@
---
Language: Cpp
BasedOnStyle: LLVM
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignOperands: false
AlignTrailingComments: false
AlwaysBreakTemplateDeclarations: Yes
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: true
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: true
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakConstructorInitializers: AfterColon
BreakConstructorInitializersBeforeComma: false
ColumnLimit: 120
ConstructorInitializerAllOnOneLineOrOnePerLine: false
IndentAccessModifiers: false
AccessModifierOffset: 0
ContinuationIndentWidth: 0
IncludeCategories:
- Regex: '^<.*'
Priority: 1
- Regex: '^".*'
Priority: 2
- Regex: '.*'
Priority: 3
IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseBlocks: true
InsertNewlineAtEOF: true
MacroBlockBegin: ''
MacroBlockEnd: ''
SortIncludes: Never
MaxEmptyLinesToKeep: 2
NamespaceIndentation: Inner
SpaceInEmptyParentheses: false
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
TabWidth: 4
IndentWidth: 4
...
+1 -1
View File
@@ -1,5 +1,5 @@
#pragma once
#include <ircolib/types.hpp>
#include "types.hpp"
#include <fstream>
#include <vector>
#include <filesystem>
+11 -11
View File
@@ -1,9 +1,9 @@
#pragma once
#include <cmath>
#include <ircolib/types.hpp>
#include "types.hpp"
namespace ircolib {
static inline auto round_ceil(float f) {
static inline auto roundCeil(float f) {
#ifdef SIMD_SUPPORT
__m128 t = _mm_set_ss(f);
t = _mm_round_ss(t, t, _MM_FROUND_TO_POS_INF);
@@ -13,7 +13,7 @@ static inline auto round_ceil(float f) {
#endif
}
static inline auto round_ceil(double f) {
static inline auto roundCeil(double f) {
#ifdef SIMD_SUPPORT
__m128d t = _mm_set_sd(f);
t = _mm_round_sd(t, t, _MM_FROUND_TO_POS_INF);
@@ -23,7 +23,7 @@ static inline auto round_ceil(double f) {
#endif
}
static inline auto round_nearest(float f) {
static inline auto roundNearest(float f) {
#ifdef SIMD_SUPPORT
__m128 t = _mm_set_ss(f);
t = _mm_round_ss(t, t, _MM_FROUND_TO_NEAREST_INT);
@@ -33,7 +33,7 @@ static inline auto round_nearest(float f) {
#endif
}
static inline auto round_nearest(double f) {
static inline auto roundNearest(double f) {
#ifdef SIMD_SUPPORT
__m128d t = _mm_set_sd(f);
t = _mm_round_sd(t, t, _MM_FROUND_TO_NEAREST_INT);
@@ -43,7 +43,7 @@ static inline auto round_nearest(double f) {
#endif
}
static inline auto round_current(float f) {
static inline auto roundCurrent(float f) {
#ifdef SIMD_SUPPORT
auto t = _mm_set_ss(f);
t = _mm_round_ss(t, t, _MM_FROUND_CUR_DIRECTION);
@@ -53,7 +53,7 @@ static inline auto round_current(float f) {
#endif
}
static inline auto round_current(double f) {
static inline auto roundCurrent(double f) {
#ifdef SIMD_SUPPORT
auto t = _mm_set_sd(f);
t = _mm_round_sd(t, t, _MM_FROUND_CUR_DIRECTION);
@@ -64,7 +64,7 @@ static inline auto round_current(double f) {
}
static inline auto round_floor(float f) {
static inline auto roundFloor(float f) {
#ifdef SIMD_SUPPORT
__m128 t = _mm_set_ss(f);
t = _mm_round_ss(t, t, _MM_FROUND_TO_NEG_INF);
@@ -74,7 +74,7 @@ static inline auto round_floor(float f) {
#endif
}
static inline auto round_floor(double f) {
static inline auto roundFloor(double f) {
#ifdef SIMD_SUPPORT
__m128d t = _mm_set_sd(f);
t = _mm_round_sd(t, t, _MM_FROUND_TO_NEG_INF);
@@ -84,7 +84,7 @@ static inline auto round_floor(double f) {
#endif
}
static inline auto round_trunc(float f) {
static inline auto roundTrunc(float f) {
#ifdef SIMD_SUPPORT
__m128 t = _mm_set_ss(f);
t = _mm_round_ss(t, t, _MM_FROUND_TO_ZERO);
@@ -94,7 +94,7 @@ static inline auto round_trunc(float f) {
#endif
}
static inline auto round_trunc(double f) {
static inline auto roundTrunc(double f) {
#ifdef SIMD_SUPPORT
__m128d t = _mm_set_sd(f);
t = _mm_round_sd(t, t, _MM_FROUND_TO_ZERO);
+2 -1
View File
@@ -1,5 +1,6 @@
#pragma once
#include <ircolib/types.hpp>
#include "types.hpp"
#include <cstddef>
#include <cstring>
#include <functional>
#include <bit>
+5
View File
@@ -30,6 +30,11 @@ template <typename T>
inline void set_bit(T &val, const std::size_t &bit) {
val |= 1 << bit;
}
template <typename T>
inline void clear_bit(T &val, const std::size_t &bit) {
val &= ~(1 << bit);
}
} // namespace ircolib
constexpr ircolib::u32 operator""_kib(const unsigned long long v) { return v * 1024; }