feat(cpu): implement skipBios method

This commit is contained in:
Rekai Nyangadzayi Musuka 2022-01-02 14:58:39 -06:00
parent eb37d73cb2
commit dee0e113d8
3 changed files with 16 additions and 1 deletions

View File

@ -30,7 +30,7 @@ pub const Io = struct {
pub fn write16(self: *@This(), addr: u32, halfword: u16) void { pub fn write16(self: *@This(), addr: u32, halfword: u16) void {
switch (addr) { switch (addr) {
0x0400_000 => self.dispcnt.val = halfword, 0x0400_000 => self.dispcnt.val = halfword,
else => std.debug.panic("[I/O:16] tried to write {X:} to {X:}", .{ halfword, addr }), else => std.debug.panic("[I/O:16] tried to write 0x{X:} to 0x{X:}", .{ halfword, addr }),
} }
} }

View File

@ -29,6 +29,19 @@ pub const Arm7tdmi = struct {
}; };
} }
pub fn skipBios(self: *@This()) void {
self.r[0] = 0x08000000;
self.r[1] = 0x000000EA;
// GPRs 2 -> 12 *should* already be 0 initialized
self.r[13] = 0x0300_7F00;
self.r[14] = 0x0000_0000;
self.r[15] = 0x0800_0000;
// TODO: Set sp_irq = 0x0300_7FA0, sp_svc = 0x0300_7FE0
self.cpsr.val = 0x6000001F;
}
pub inline fn step(self: *@This()) u64 { pub inline fn step(self: *@This()) u64 {
std.debug.print("PC: 0x{X:} ", .{self.r[15]}); std.debug.print("PC: 0x{X:} ", .{self.r[15]});
const opcode = self.fetch(); const opcode = self.fetch();

View File

@ -27,6 +27,8 @@ pub fn main() anyerror!void {
var scheduler = Scheduler.init(alloc); var scheduler = Scheduler.init(alloc);
var cpu = Arm7tdmi.init(&scheduler, &bus); var cpu = Arm7tdmi.init(&scheduler, &bus);
cpu.skipBios();
while (true) { while (true) {
emu.runFrame(&scheduler, &cpu, &bus); emu.runFrame(&scheduler, &cpu, &bus);
} }