chore: remove premature inlines
This commit is contained in:
parent
c4c4332485
commit
357211a4cc
|
@ -22,17 +22,17 @@ pub fn deinit(self: Self) void {
|
||||||
self.alloc.free(self.buf);
|
self.alloc.free(self.buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn get32(self: *const Self, idx: usize) u32 {
|
pub fn get32(self: *const Self, idx: usize) u32 {
|
||||||
std.debug.panic("[BIOS] TODO: BIOS is not implemented", .{});
|
std.debug.panic("[BIOS] TODO: BIOS is not implemented", .{});
|
||||||
return (@as(u32, self.buf[idx + 3]) << 24) | (@as(u32, self.buf[idx + 2]) << 16) | (@as(u32, self.buf[idx + 1]) << 8) | (@as(u32, self.buf[idx]));
|
return (@as(u32, self.buf[idx + 3]) << 24) | (@as(u32, self.buf[idx + 2]) << 16) | (@as(u32, self.buf[idx + 1]) << 8) | (@as(u32, self.buf[idx]));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn get16(self: *const Self, idx: usize) u16 {
|
pub fn get16(self: *const Self, idx: usize) u16 {
|
||||||
std.debug.panic("[BIOS] TODO: BIOS is not implemented", .{});
|
std.debug.panic("[BIOS] TODO: BIOS is not implemented", .{});
|
||||||
return (@as(u16, self.buf[idx + 1]) << 8) | @as(u16, self.buf[idx]);
|
return (@as(u16, self.buf[idx + 1]) << 8) | @as(u16, self.buf[idx]);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn get8(self: *const Self, idx: usize) u8 {
|
pub fn get8(self: *const Self, idx: usize) u8 {
|
||||||
std.debug.panic("[BIOS] TODO: BIOS is not implemented", .{});
|
std.debug.panic("[BIOS] TODO: BIOS is not implemented", .{});
|
||||||
return self.buf[idx];
|
return self.buf[idx];
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,14 +22,14 @@ pub fn deinit(self: Self) void {
|
||||||
self.alloc.free(self.buf);
|
self.alloc.free(self.buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn get32(self: *const Self, idx: usize) u32 {
|
pub fn get32(self: *const Self, idx: usize) u32 {
|
||||||
return (@as(u32, self.get16(idx + 2)) << 16) | @as(u32, self.get16(idx));
|
return (@as(u32, self.get16(idx + 2)) << 16) | @as(u32, self.get16(idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn get16(self: *const Self, idx: usize) u16 {
|
pub fn get16(self: *const Self, idx: usize) u16 {
|
||||||
return (@as(u16, self.buf[idx + 1]) << 8) | @as(u16, self.buf[idx]);
|
return (@as(u16, self.buf[idx + 1]) << 8) | @as(u16, self.buf[idx]);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn get8(self: *const Self, idx: usize) u8 {
|
pub fn get8(self: *const Self, idx: usize) u8 {
|
||||||
return self.buf[idx];
|
return self.buf[idx];
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ pub const Arm7tdmi = struct {
|
||||||
self.cpsr.raw = 0x6000001F;
|
self.cpsr.raw = 0x6000001F;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn step(self: *Self) u64 {
|
pub fn step(self: *Self) u64 {
|
||||||
const opcode = self.fetch();
|
const opcode = self.fetch();
|
||||||
// self.mgbaLog(opcode);
|
// self.mgbaLog(opcode);
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ const std = @import("std");
|
||||||
const Arm7tdmi = @import("../cpu.zig").Arm7tdmi;
|
const Arm7tdmi = @import("../cpu.zig").Arm7tdmi;
|
||||||
const CPSR = @import("../cpu.zig").CPSR;
|
const CPSR = @import("../cpu.zig").CPSR;
|
||||||
|
|
||||||
pub inline fn exec(comptime S: bool, cpu: *Arm7tdmi, opcode: u32) u32 {
|
pub fn exec(comptime S: bool, cpu: *Arm7tdmi, opcode: u32) u32 {
|
||||||
var shift_amt: u8 = undefined;
|
var shift_amt: u8 = undefined;
|
||||||
if (opcode >> 4 & 1 == 1) {
|
if (opcode >> 4 & 1 == 1) {
|
||||||
shift_amt = @truncate(u8, cpu.r[opcode >> 8 & 0xF]);
|
shift_amt = @truncate(u8, cpu.r[opcode >> 8 & 0xF]);
|
||||||
|
@ -31,7 +31,7 @@ pub inline fn exec(comptime S: bool, cpu: *Arm7tdmi, opcode: u32) u32 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn logical_left(cpsr: *CPSR, rm: u32, shift_byte: u8) u32 {
|
pub fn logical_left(cpsr: *CPSR, rm: u32, shift_byte: u8) u32 {
|
||||||
const shift_amt = @truncate(u5, shift_byte);
|
const shift_amt = @truncate(u5, shift_byte);
|
||||||
const bit_count: u8 = @typeInfo(u32).Int.bits;
|
const bit_count: u8 = @typeInfo(u32).Int.bits;
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ pub inline fn logical_left(cpsr: *CPSR, rm: u32, shift_byte: u8) u32 {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn logical_right(cpsr: *CPSR, rm: u32, shift_byte: u8) u32 {
|
pub fn logical_right(cpsr: *CPSR, rm: u32, shift_byte: u8) u32 {
|
||||||
const shift_amt = @truncate(u5, shift_byte);
|
const shift_amt = @truncate(u5, shift_byte);
|
||||||
const bit_count: u8 = @typeInfo(u32).Int.bits;
|
const bit_count: u8 = @typeInfo(u32).Int.bits;
|
||||||
|
|
||||||
|
|
20
src/ppu.zig
20
src/ppu.zig
|
@ -72,25 +72,25 @@ const Palette = struct {
|
||||||
self.alloc.free(self.buf);
|
self.alloc.free(self.buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn get32(self: *const Self, idx: usize) u32 {
|
pub fn get32(self: *const Self, idx: usize) u32 {
|
||||||
return (@as(u32, self.get16(idx + 2)) << 16) | @as(u32, self.get16(idx));
|
return (@as(u32, self.get16(idx + 2)) << 16) | @as(u32, self.get16(idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn set32(self: *Self, idx: usize, word: u32) void {
|
pub fn set32(self: *Self, idx: usize, word: u32) void {
|
||||||
self.set16(idx + 2, @truncate(u16, word >> 16));
|
self.set16(idx + 2, @truncate(u16, word >> 16));
|
||||||
self.set16(idx, @truncate(u16, word));
|
self.set16(idx, @truncate(u16, word));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn get16(self: *const Self, idx: usize) u16 {
|
pub fn get16(self: *const Self, idx: usize) u16 {
|
||||||
return (@as(u16, self.buf[idx + 1]) << 8) | @as(u16, self.buf[idx]);
|
return (@as(u16, self.buf[idx + 1]) << 8) | @as(u16, self.buf[idx]);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn set16(self: *Self, idx: usize, halfword: u16) void {
|
pub fn set16(self: *Self, idx: usize, halfword: u16) void {
|
||||||
self.buf[idx + 1] = @truncate(u8, halfword >> 8);
|
self.buf[idx + 1] = @truncate(u8, halfword >> 8);
|
||||||
self.buf[idx] = @truncate(u8, halfword);
|
self.buf[idx] = @truncate(u8, halfword);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn get8(self: *const Self, idx: usize) u8 {
|
pub fn get8(self: *const Self, idx: usize) u8 {
|
||||||
return self.buf[idx];
|
return self.buf[idx];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -112,25 +112,25 @@ const Vram = struct {
|
||||||
self.alloc.free(self.buf);
|
self.alloc.free(self.buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn get32(self: *const Self, idx: usize) u32 {
|
pub fn get32(self: *const Self, idx: usize) u32 {
|
||||||
return (@as(u32, self.get16(idx + 2)) << 16) | @as(u32, self.get16(idx));
|
return (@as(u32, self.get16(idx + 2)) << 16) | @as(u32, self.get16(idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn set32(self: *Self, idx: usize, word: u32) void {
|
pub fn set32(self: *Self, idx: usize, word: u32) void {
|
||||||
self.set16(idx + 2, @truncate(u16, word >> 16));
|
self.set16(idx + 2, @truncate(u16, word >> 16));
|
||||||
self.set16(idx, @truncate(u16, word));
|
self.set16(idx, @truncate(u16, word));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn get16(self: *const Self, idx: usize) u16 {
|
pub fn get16(self: *const Self, idx: usize) u16 {
|
||||||
return (@as(u16, self.buf[idx + 1]) << 8) | @as(u16, self.buf[idx]);
|
return (@as(u16, self.buf[idx + 1]) << 8) | @as(u16, self.buf[idx]);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn set16(self: *Self, idx: usize, halfword: u16) void {
|
pub fn set16(self: *Self, idx: usize, halfword: u16) void {
|
||||||
self.buf[idx + 1] = @truncate(u8, halfword >> 8);
|
self.buf[idx + 1] = @truncate(u8, halfword >> 8);
|
||||||
self.buf[idx] = @truncate(u8, halfword);
|
self.buf[idx] = @truncate(u8, halfword);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn get8(self: *const Self, idx: usize) u8 {
|
pub fn get8(self: *const Self, idx: usize) u8 {
|
||||||
return self.buf[idx];
|
return self.buf[idx];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -84,11 +84,11 @@ pub const Scheduler = struct {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn push(self: *Self, kind: EventKind, end: u64) void {
|
pub fn push(self: *Self, kind: EventKind, end: u64) void {
|
||||||
self.queue.add(.{ .kind = kind, .tick = end }) catch unreachable;
|
self.queue.add(.{ .kind = kind, .tick = end }) catch unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn nextTimestamp(self: *Self) u64 {
|
pub fn nextTimestamp(self: *Self) u64 {
|
||||||
if (self.queue.peek()) |e| {
|
if (self.queue.peek()) |e| {
|
||||||
return e.tick;
|
return e.tick;
|
||||||
} else unreachable;
|
} else unreachable;
|
||||||
|
|
Loading…
Reference in New Issue