Compare commits
No commits in common. "ca67ca318359af33157ea66f6f234220242310c9" and "472215b4c20163a5ba08c7bc8aef021d758b0db0" have entirely different histories.
ca67ca3183
...
472215b4c2
|
@ -473,15 +473,11 @@ pub const Apu = struct {
|
||||||
if (!self.cnt.apu_enable.read()) return;
|
if (!self.cnt.apu_enable.read()) return;
|
||||||
|
|
||||||
if (@boolToInt(self.dma_cnt.chA_timer.read()) == tim_id) {
|
if (@boolToInt(self.dma_cnt.chA_timer.read()) == tim_id) {
|
||||||
if (!self.chA.enabled) return;
|
|
||||||
|
|
||||||
self.chA.updateSample();
|
self.chA.updateSample();
|
||||||
if (self.chA.len() <= 15) cpu.bus.dma[1].requestAudio(0x0400_00A0);
|
if (self.chA.len() <= 15) cpu.bus.dma[1].requestAudio(0x0400_00A0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (@boolToInt(self.dma_cnt.chB_timer.read()) == tim_id) {
|
if (@boolToInt(self.dma_cnt.chB_timer.read()) == tim_id) {
|
||||||
if (!self.chB.enabled) return;
|
|
||||||
|
|
||||||
self.chB.updateSample();
|
self.chB.updateSample();
|
||||||
if (self.chB.len() <= 15) cpu.bus.dma[2].requestAudio(0x0400_00A4);
|
if (self.chB.len() <= 15) cpu.bus.dma[2].requestAudio(0x0400_00A4);
|
||||||
}
|
}
|
||||||
|
@ -495,29 +491,19 @@ pub fn DmaSound(comptime kind: DmaSoundKind) type {
|
||||||
fifo: SoundFifo,
|
fifo: SoundFifo,
|
||||||
kind: DmaSoundKind,
|
kind: DmaSoundKind,
|
||||||
sample: i8,
|
sample: i8,
|
||||||
enabled: bool,
|
|
||||||
|
|
||||||
fn init() Self {
|
fn init() Self {
|
||||||
return .{
|
return .{
|
||||||
.fifo = SoundFifo.init(),
|
.fifo = SoundFifo.init(),
|
||||||
.kind = kind,
|
.kind = kind,
|
||||||
.sample = 0,
|
.sample = 0,
|
||||||
.enabled = false,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn push(self: *Self, value: u32) void {
|
pub fn push(self: *Self, value: u32) void {
|
||||||
// FIXME: I tried to communicate that this is unlikely to the compiler
|
|
||||||
if (!self.enabled) self.enable();
|
|
||||||
|
|
||||||
self.fifo.write(&intToBytes(u32, value)) catch |e| log.err("{} Error: {}", .{ kind, e });
|
self.fifo.write(&intToBytes(u32, value)) catch |e| log.err("{} Error: {}", .{ kind, e });
|
||||||
}
|
}
|
||||||
|
|
||||||
fn enable(self: *Self) void {
|
|
||||||
@setCold(true);
|
|
||||||
self.enabled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn len(self: *const Self) usize {
|
pub fn len(self: *const Self) usize {
|
||||||
return self.fifo.readableLength();
|
return self.fifo.readableLength();
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,8 +105,7 @@ pub fn runFrame(sched: *Scheduler, cpu: *Arm7tdmi) void {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn audioSync(audio_sync: bool, stream: *SDL.SDL_AudioStream, is_buffer_full: *bool) void {
|
fn audioSync(audio_sync: bool, stream: *SDL.SDL_AudioStream, is_buffer_full: *bool) void {
|
||||||
comptime std.debug.assert(@import("../platform.zig").sample_format == SDL.AUDIO_F32);
|
const sample_size = 2 * @sizeOf(u16);
|
||||||
const sample_size = 2 * @sizeOf(f32);
|
|
||||||
const max_buf_size: c_int = 0x400;
|
const max_buf_size: c_int = 0x400;
|
||||||
|
|
||||||
// Determine whether the APU is busy right at this moment
|
// Determine whether the APU is busy right at this moment
|
||||||
|
|
|
@ -202,10 +202,7 @@ pub const Gui = struct {
|
||||||
SDL.SDLK_s => io.keyinput.shoulder_r.set(),
|
SDL.SDLK_s => io.keyinput.shoulder_r.set(),
|
||||||
SDL.SDLK_RETURN => io.keyinput.start.set(),
|
SDL.SDLK_RETURN => io.keyinput.start.set(),
|
||||||
SDL.SDLK_RSHIFT => io.keyinput.select.set(),
|
SDL.SDLK_RSHIFT => io.keyinput.select.set(),
|
||||||
SDL.SDLK_i => {
|
SDL.SDLK_i => log.err("Sample Count: {}", .{@intCast(u32, SDL.SDL_AudioStreamAvailable(cpu.bus.apu.stream)) / (2 * @sizeOf(u16))}),
|
||||||
comptime std.debug.assert(sample_format == SDL.AUDIO_F32);
|
|
||||||
log.err("Sample Count: {}", .{@intCast(u32, SDL.SDL_AudioStreamAvailable(cpu.bus.apu.stream)) / (2 * @sizeOf(f32))});
|
|
||||||
},
|
|
||||||
SDL.SDLK_j => log.err("Scheduler Capacity: {} | Scheduler Event Count: {}", .{ scheduler.queue.capacity(), scheduler.queue.count() }),
|
SDL.SDLK_j => log.err("Scheduler Capacity: {} | Scheduler Event Count: {}", .{ scheduler.queue.capacity(), scheduler.queue.count() }),
|
||||||
SDL.SDLK_k => {
|
SDL.SDLK_k => {
|
||||||
// Dump IWRAM to file
|
// Dump IWRAM to file
|
||||||
|
|
Loading…
Reference in New Issue