feat: implement ARM read open bus

This commit is contained in:
2022-04-13 23:21:25 -03:00
parent 6d5c30ac25
commit 9b9b6c0d6f
8 changed files with 115 additions and 73 deletions

View File

@@ -24,9 +24,9 @@ pub const Apu = struct {
dma_cnt: io.DmaSoundControl,
cnt: io.SoundControl,
dev: AudioDeviceId,
dev: ?AudioDeviceId,
pub fn init(dev: AudioDeviceId) Self {
pub fn init() Self {
return .{
.ch1 = ToneSweep.init(),
.ch2 = Tone.init(),
@@ -40,10 +40,14 @@ pub const Apu = struct {
.cnt = .{ .raw = 0 },
.bias = .{ .raw = 0x0200 },
.dev = dev,
.dev = null,
};
}
pub fn attachAudioDevice(self: *Self, dev: AudioDeviceId) void {
self.dev = dev;
}
pub fn setDmaCnt(self: *Self, value: u16) void {
const new: io.DmaSoundControl = .{ .raw = value };
@@ -83,7 +87,7 @@ pub const Apu = struct {
},
};
_ = SDL.SDL_QueueAudio(self.dev, &samples, 2);
if (self.dev) |dev| _ = SDL.SDL_QueueAudio(dev, &samples, 2);
}
};