chore: tick scheduler on memory access

This commit is contained in:
2022-10-21 05:12:33 -03:00
parent a4020400da
commit e69f4cfafe
6 changed files with 34 additions and 34 deletions

View File

@@ -29,9 +29,10 @@ dma: DmaControllers,
tim: Timers,
iwram: Iwram,
ewram: Ewram,
io: Io,
sched: *Scheduler,
pub fn init(alloc: Allocator, sched: *Scheduler, rom_path: []const u8, bios_path: ?[]const u8, save_path: ?[]const u8) !Self {
return Self{
.pak = try GamePak.init(alloc, rom_path, save_path),
@@ -43,6 +44,7 @@ pub fn init(alloc: Allocator, sched: *Scheduler, rom_path: []const u8, bios_path
.dma = DmaControllers.init(),
.tim = Timers.init(sched),
.io = Io.init(),
.sched = sched,
};
}
@@ -57,6 +59,7 @@ pub fn deinit(self: Self) void {
pub fn read(self: *const Self, comptime T: type, address: u32) T {
const page = @truncate(u8, address >> 24);
const align_addr = alignAddress(T, address);
self.sched.tick += 1;
return switch (page) {
// General Internal Memory
@@ -91,6 +94,7 @@ pub fn read(self: *const Self, comptime T: type, address: u32) T {
pub fn write(self: *Self, comptime T: type, address: u32, value: T) void {
const page = @truncate(u8, address >> 24);
const align_addr = alignAddress(T, address);
self.sched.tick += 1;
switch (page) {
// General Internal Memory