diff --git a/simulator/src/apu-worklet.ts b/simulator/src/apu-worklet.ts index 253c4cb..f2f3954 100644 --- a/simulator/src/apu-worklet.ts +++ b/simulator/src/apu-worklet.ts @@ -34,8 +34,6 @@ class APUProcessor extends AudioWorkletProcessor { outputRight[index] = pcmRight[index] / 32767; } - console.log(pcmLeft.length); - return true; } } diff --git a/simulator/src/constants.ts b/simulator/src/constants.ts index 7bbb963..a9db9a7 100644 --- a/simulator/src/constants.ts +++ b/simulator/src/constants.ts @@ -12,8 +12,8 @@ export const ADDR_LIGHT_LEVEL = 0x06; export const ADDR_NEOPIXELS = 0x08; export const ADDR_RED_LED = 0x1c; export const ADDR_BATTERY_LEVEL = 0x1e; -export const ADDR_FRAMEBUFFER = 0x20; -export const ADDR_AUDIO_BUFFER = 0xb01e; +export const ADDR_FRAMEBUFFER = 0x1e; +export const ADDR_AUDIO_BUFFER = 0xa020; export const CONTROLS_START = 1; export const CONTROLS_SELECT = 2; diff --git a/src/badge/cart.zig b/src/badge/cart.zig index 1e9ba2c..16f6a78 100644 --- a/src/badge/cart.zig +++ b/src/badge/cart.zig @@ -38,8 +38,8 @@ pub fn svcall_handler() callconv(.Naked) void { \\ cmp r3, #0xDF \\ bne 12f \\ ldrb r3, [r2, #0 * 1] - \\ cmp r3, #12 - \\ bhi 13f + \\ cmp r3, #11 + \\ bhi 12f \\ tbb [pc, r3] \\0: \\ .byte (0f - 0b) / 2 @@ -49,12 +49,12 @@ pub fn svcall_handler() callconv(.Naked) void { \\ .byte (4f - 0b) / 2 \\ .byte (5f - 0b) / 2 \\ .byte (6f - 0b) / 2 + \\ .byte (7f - 0b) / 2 \\ .byte (8f - 0b) / 2 \\ .byte (9f - 0b) / 2 \\ .byte (10f - 0b) / 2 + \\12: \\ .byte (11f - 0b) / 2 - \\13: - \\ .byte (12f - 0b) / 2 \\ .byte 0xDE \\ .align 1 \\0: @@ -78,18 +78,18 @@ pub fn svcall_handler() callconv(.Naked) void { \\6: \\ ldm r1, {r0-r3} \\ b %[vline:P] - \\8: + \\7: \\ ldm r1, {r0-r2} \\ b %[read_flash:P] - \\9: + \\8: \\ ldm r1, {r0-r1} \\ b %[write_flash_page:P] - \\10: + \\9: \\ b %[rand:P] - \\11: + \\10: \\ ldm r1, {r0-r1} \\ b %[trace:P] - \\12: + \\11: \\ lsrs r0, #31 \\ msr control, r0 \\ it eq diff --git a/src/badge/feature_test.zig b/src/badge/feature_test.zig index fa04fe5..c6fcb2e 100644 --- a/src/badge/feature_test.zig +++ b/src/badge/feature_test.zig @@ -158,12 +158,12 @@ export fn update() void { var wave_t: f32 = 0; export fn audio() void { - for (&cart.audio_buffer[0], &cart.audio_buffer[1]) |*l, *r| { - const val: i16 = @intFromFloat(@sin(wave_t) * std.math.maxInt(i16)); + // for (&cart.audio_buffer[0], &cart.audio_buffer[1]) |*l, *r| { + // const val: i16 = @intFromFloat(@sin(wave_t) * std.math.maxInt(i16)); - l.* = val; - r.* = val; + // l.* = val; + // r.* = val; - wave_t += 0.1; - } + // wave_t += 0.1; + // } } diff --git a/src/board/audio.zig b/src/board/audio.zig index 38dac8f..c13288c 100644 --- a/src/board/audio.zig +++ b/src/board/audio.zig @@ -1,5 +1,5 @@ pub const sample_buffer: *volatile [2][512]i16 = @ptrFromInt(0x20000000 + 0xa020); -var call_audio: *const fn () void = undefined; +var call_audio: ?*const fn () void = null; pub fn init(call_audio_fn: *const fn () void) void { @setCold(true); @@ -185,15 +185,16 @@ pub fn init(call_audio_fn: *const fn () void) void { } pub fn mix() callconv(.C) void { - var speaker_enable: port.Level = .low; + // var speaker_enable: port.Level = .low; + const speaker_enable: port.Level = .low; - call_audio(); + // if (call_audio) |ca| ca(); - for (&sample_buffer[ - (dma.get_audio_part() + sample_buffer.len - 1) % sample_buffer.len - ]) |sample| { - if (sample != 0) speaker_enable = .high; - } + // for (&sample_buffer[ + // (dma.get_audio_part() + sample_buffer.len - 1) % sample_buffer.len + // ]) |sample| { + // if (sample != 0) speaker_enable = .high; + // } board.SPKR_EN.write(speaker_enable); dma.ack_audio(); diff --git a/src/cart.ld b/src/cart.ld index bc4e833..dcc49fc 100644 --- a/src/cart.ld +++ b/src/cart.ld @@ -12,8 +12,8 @@ MEMORY bootloader (rx!w) : ORIGIN = 0x00000000, LENGTH = 0x00004000 runtime_flash (rx!w) : ORIGIN = 0x00004000, LENGTH = 0x0002C000 cart_flash (rx!w) : ORIGIN = 0x00030000, LENGTH = 0x00080000 - cart_fixed (rw!x) : ORIGIN = 0x20000000, LENGTH = 0x0000A020 - cart_ram (rw!x) : ORIGIN = 0x2000A020, LENGTH = 0x00015FE0 + cart_fixed (rw!x) : ORIGIN = 0x20000000, LENGTH = 0x0000A820 + cart_ram (rw!x) : ORIGIN = 0x2000A820, LENGTH = 0x000157E0 runtime_ram (rw!x) : ORIGIN = 0x20020000, LENGTH = 0x00008000 cart_stack (rw!x) : ORIGIN = 0x20028000, LENGTH = 0x00004000 runtime_stack (rw!x) : ORIGIN = 0x2002C000, LENGTH = 0x00004000 diff --git a/src/cart/api.zig b/src/cart/api.zig index 5cf2169..5b5aba6 100644 --- a/src/cart/api.zig +++ b/src/cart/api.zig @@ -86,7 +86,7 @@ pub const neopixels: *[5]NeopixelColor = @ptrFromInt(base + 0x08); pub const red_led: *bool = @ptrFromInt(base + 0x1c); pub const battery_level: *u12 = @ptrFromInt(base + 0x1e); pub const framebuffer: *volatile [screen_width][screen_height]Pixel = @ptrFromInt(base + 0x20); -pub const audio_buffer: *volatile [2][512]i16 = @ptrFromInt(base + 0xa020); +// pub const audio_buffer: *volatile [2][512]i16 = @ptrFromInt(base + 0xa020); pub const BlitOptions = struct { pub const Flags = packed struct(u32) { @@ -428,7 +428,7 @@ pub inline fn read_flash(offset: u32, dst: []u8) u32 { } else { var clobber_r1: usize = undefined; var clobber_r2: usize = undefined; - return asm volatile (" svc #8" + return asm volatile (" svc #7" : [result] "={r0}" (-> u32), [clobber_r1] "={r1}" (clobber_r1), [clobber_r2] "={r2}" (clobber_r2), @@ -448,7 +448,7 @@ pub inline fn write_flash_page(page: u16, src: [flash_page_size]u8) void { } else { var clobber_r0: usize = undefined; var clobber_r1: usize = undefined; - asm volatile (" svc #9" + asm volatile (" svc #8" : [clobber_r0] "={r0}" (clobber_r0), [clobber_r1] "={r1}" (clobber_r1), : [page] "{r0}" (page), @@ -465,7 +465,7 @@ pub inline fn rand() u32 { extern fn rand() u32; }.rand(); } else { - return asm volatile (" svc #10" + return asm volatile (" svc #9" : [result] "={r0}" (-> u32), : : "r1", "r2", "r3" @@ -482,7 +482,7 @@ pub inline fn trace(x: []const u8) void { } else { var clobber_r0: usize = undefined; var clobber_r1: usize = undefined; - asm volatile (" svc #11" + asm volatile (" svc #10" : [clobber_r0] "={r0}" (clobber_r0), [clobber_r1] "={r1}" (clobber_r1), : [x_ptr] "{r0}" (x.ptr),