From 14b24787ab248450856674a9efdd69a79e86aa91 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Fri, 28 Oct 2022 21:56:34 -0300 Subject: [PATCH] style: remove unnecessary imports --- src/core/Bus.zig | 1 - src/core/apu.zig | 4 +--- src/core/apu/signal/Lfsr.zig | 4 +--- src/core/apu/signal/Square.zig | 1 - src/core/apu/signal/Wave.zig | 2 -- src/core/bus/GamePak.zig | 4 ---- src/core/bus/gpio.zig | 1 - src/core/bus/io.zig | 3 --- src/core/bus/timer.zig | 2 -- src/core/cpu.zig | 2 -- src/core/cpu/arm/branch.zig | 2 -- src/core/cpu/arm/half_signed_data_transfer.zig | 2 -- src/core/cpu/arm/single_data_swap.zig | 2 -- src/core/cpu/arm/single_data_transfer.zig | 3 --- src/core/cpu/barrel_shifter.zig | 2 -- src/core/cpu/thumb/data_processing.zig | 2 -- src/core/cpu/thumb/data_transfer.zig | 2 -- src/core/emu.zig | 4 ---- src/core/ppu.zig | 1 - src/core/scheduler.zig | 1 - src/platform.zig | 8 ++++++-- 21 files changed, 8 insertions(+), 45 deletions(-) diff --git a/src/core/Bus.zig b/src/core/Bus.zig index 39d68bb..a13e83b 100644 --- a/src/core/Bus.zig +++ b/src/core/Bus.zig @@ -1,6 +1,5 @@ const std = @import("std"); -const AudioDeviceId = @import("sdl2").SDL_AudioDeviceID; const Arm7tdmi = @import("cpu.zig").Arm7tdmi; const Bios = @import("bus/Bios.zig"); const Ewram = @import("bus/Ewram.zig"); diff --git a/src/core/apu.zig b/src/core/apu.zig index afa7d6b..8f2ba0b 100644 --- a/src/core/apu.zig +++ b/src/core/apu.zig @@ -3,8 +3,6 @@ const SDL = @import("sdl2"); const io = @import("bus/io.zig"); const util = @import("../util.zig"); -const AudioDeviceId = SDL.SDL_AudioDeviceID; - const Arm7tdmi = @import("cpu.zig").Arm7tdmi; const Scheduler = @import("scheduler.zig").Scheduler; const ToneSweep = @import("apu/ToneSweep.zig"); @@ -457,8 +455,8 @@ const DmaSoundKind = enum { }; pub const FrameSequencer = struct { - const interval = (1 << 24) / 512; const Self = @This(); + pub const interval = (1 << 24) / 512; step: u3, diff --git a/src/core/apu/signal/Lfsr.zig b/src/core/apu/signal/Lfsr.zig index 6d7a704..63a9dd4 100644 --- a/src/core/apu/signal/Lfsr.zig +++ b/src/core/apu/signal/Lfsr.zig @@ -1,9 +1,7 @@ +//! Linear Feedback Shift Register const io = @import("../../bus/io.zig"); -/// Linear Feedback Shift Register const Scheduler = @import("../../scheduler.zig").Scheduler; -const FrameSequencer = @import("../../apu.zig").FrameSequencer; -const Noise = @import("../Noise.zig"); const Self = @This(); pub const interval: u64 = (1 << 24) / (1 << 22); diff --git a/src/core/apu/signal/Square.zig b/src/core/apu/signal/Square.zig index c026f41..3429bd0 100644 --- a/src/core/apu/signal/Square.zig +++ b/src/core/apu/signal/Square.zig @@ -2,7 +2,6 @@ const std = @import("std"); const io = @import("../../bus/io.zig"); const Scheduler = @import("../../scheduler.zig").Scheduler; -const FrameSequencer = @import("../../apu.zig").FrameSequencer; const ToneSweep = @import("../ToneSweep.zig"); const Tone = @import("../Tone.zig"); diff --git a/src/core/apu/signal/Wave.zig b/src/core/apu/signal/Wave.zig index f7c852e..c7944c8 100644 --- a/src/core/apu/signal/Wave.zig +++ b/src/core/apu/signal/Wave.zig @@ -2,8 +2,6 @@ const std = @import("std"); const io = @import("../../bus/io.zig"); const Scheduler = @import("../../scheduler.zig").Scheduler; -const FrameSequencer = @import("../../apu.zig").FrameSequencer; -const Wave = @import("../Wave.zig"); const buf_len = 0x20; pub const interval: u64 = (1 << 24) / (1 << 22); diff --git a/src/core/bus/GamePak.zig b/src/core/bus/GamePak.zig index 6b8ee54..d7cd605 100644 --- a/src/core/bus/GamePak.zig +++ b/src/core/bus/GamePak.zig @@ -1,10 +1,6 @@ const std = @import("std"); const config = @import("../../config.zig"); -const Bit = @import("bitfield").Bit; -const Bitfield = @import("bitfield").Bitfield; -const DateTime = @import("datetime").datetime.Datetime; - const Arm7tdmi = @import("../cpu.zig").Arm7tdmi; const Backup = @import("backup.zig").Backup; const Gpio = @import("gpio.zig").Gpio; diff --git a/src/core/bus/gpio.zig b/src/core/bus/gpio.zig index 60a430d..c9b7891 100644 --- a/src/core/bus/gpio.zig +++ b/src/core/bus/gpio.zig @@ -1,6 +1,5 @@ const std = @import("std"); const Bit = @import("bitfield").Bit; -const Bitfield = @import("bitfield").Bitfield; const DateTime = @import("datetime").datetime.Datetime; const Arm7tdmi = @import("../cpu.zig").Arm7tdmi; diff --git a/src/core/bus/io.zig b/src/core/bus/io.zig index 08ed08f..5da1700 100644 --- a/src/core/bus/io.zig +++ b/src/core/bus/io.zig @@ -1,5 +1,4 @@ const std = @import("std"); -const builtin = @import("builtin"); const timer = @import("timer.zig"); const dma = @import("dma.zig"); const apu = @import("../apu.zig"); @@ -8,8 +7,6 @@ const util = @import("../../util.zig"); const Bit = @import("bitfield").Bit; const Bitfield = @import("bitfield").Bitfield; const Bus = @import("../Bus.zig"); -const DmaController = @import("dma.zig").DmaController; -const Scheduler = @import("../scheduler.zig").Scheduler; const setHi = util.setHi; const setLo = util.setLo; diff --git a/src/core/bus/timer.zig b/src/core/bus/timer.zig index 72f232a..07afa17 100644 --- a/src/core/bus/timer.zig +++ b/src/core/bus/timer.zig @@ -2,9 +2,7 @@ const std = @import("std"); const util = @import("../../util.zig"); const TimerControl = @import("io.zig").TimerControl; -const Io = @import("io.zig").Io; const Scheduler = @import("../scheduler.zig").Scheduler; -const Event = @import("../scheduler.zig").Event; const Arm7tdmi = @import("../cpu.zig").Arm7tdmi; pub const TimerTuple = std.meta.Tuple(&[_]type{ Timer(0), Timer(1), Timer(2), Timer(3) }); diff --git a/src/core/cpu.zig b/src/core/cpu.zig index 6f15cae..539547e 100644 --- a/src/core/cpu.zig +++ b/src/core/cpu.zig @@ -1,11 +1,9 @@ const std = @import("std"); -const util = @import("../util.zig"); const Bus = @import("Bus.zig"); const Bit = @import("bitfield").Bit; const Bitfield = @import("bitfield").Bitfield; const Scheduler = @import("scheduler.zig").Scheduler; -const FilePaths = @import("../util.zig").FilePaths; const Logger = @import("../util.zig").Logger; const File = std.fs.File; diff --git a/src/core/cpu/arm/branch.zig b/src/core/cpu/arm/branch.zig index c4f9594..b55782d 100644 --- a/src/core/cpu/arm/branch.zig +++ b/src/core/cpu/arm/branch.zig @@ -1,5 +1,3 @@ -const std = @import("std"); - const Bus = @import("../../Bus.zig"); const Arm7tdmi = @import("../../cpu.zig").Arm7tdmi; const InstrFn = @import("../../cpu.zig").arm.InstrFn; diff --git a/src/core/cpu/arm/half_signed_data_transfer.zig b/src/core/cpu/arm/half_signed_data_transfer.zig index d6c334a..cd205d9 100644 --- a/src/core/cpu/arm/half_signed_data_transfer.zig +++ b/src/core/cpu/arm/half_signed_data_transfer.zig @@ -1,5 +1,3 @@ -const std = @import("std"); - const Bus = @import("../../Bus.zig"); const Arm7tdmi = @import("../../cpu.zig").Arm7tdmi; const InstrFn = @import("../../cpu.zig").arm.InstrFn; diff --git a/src/core/cpu/arm/single_data_swap.zig b/src/core/cpu/arm/single_data_swap.zig index 63001f2..511cb7b 100644 --- a/src/core/cpu/arm/single_data_swap.zig +++ b/src/core/cpu/arm/single_data_swap.zig @@ -1,5 +1,3 @@ -const std = @import("std"); - const Bus = @import("../../Bus.zig"); const Arm7tdmi = @import("../../cpu.zig").Arm7tdmi; const InstrFn = @import("../../cpu.zig").arm.InstrFn; diff --git a/src/core/cpu/arm/single_data_transfer.zig b/src/core/cpu/arm/single_data_transfer.zig index 42bd217..6d56bb4 100644 --- a/src/core/cpu/arm/single_data_transfer.zig +++ b/src/core/cpu/arm/single_data_transfer.zig @@ -1,6 +1,3 @@ -const std = @import("std"); -const util = @import("../../../util.zig"); - const shifter = @import("../barrel_shifter.zig"); const Bus = @import("../../Bus.zig"); const Arm7tdmi = @import("../../cpu.zig").Arm7tdmi; diff --git a/src/core/cpu/barrel_shifter.zig b/src/core/cpu/barrel_shifter.zig index 14578b4..ecca44b 100644 --- a/src/core/cpu/barrel_shifter.zig +++ b/src/core/cpu/barrel_shifter.zig @@ -1,5 +1,3 @@ -const std = @import("std"); - const Arm7tdmi = @import("../cpu.zig").Arm7tdmi; const CPSR = @import("../cpu.zig").PSR; diff --git a/src/core/cpu/thumb/data_processing.zig b/src/core/cpu/thumb/data_processing.zig index 6d9a324..b9c3337 100644 --- a/src/core/cpu/thumb/data_processing.zig +++ b/src/core/cpu/thumb/data_processing.zig @@ -1,5 +1,3 @@ -const std = @import("std"); - const Bus = @import("../../Bus.zig"); const Arm7tdmi = @import("../../cpu.zig").Arm7tdmi; const InstrFn = @import("../../cpu.zig").thumb.InstrFn; diff --git a/src/core/cpu/thumb/data_transfer.zig b/src/core/cpu/thumb/data_transfer.zig index 3c55942..b6c5246 100644 --- a/src/core/cpu/thumb/data_transfer.zig +++ b/src/core/cpu/thumb/data_transfer.zig @@ -1,5 +1,3 @@ -const std = @import("std"); - const Bus = @import("../../Bus.zig"); const Arm7tdmi = @import("../../cpu.zig").Arm7tdmi; const InstrFn = @import("../../cpu.zig").thumb.InstrFn; diff --git a/src/core/emu.zig b/src/core/emu.zig index 5c77f20..ea4df44 100644 --- a/src/core/emu.zig +++ b/src/core/emu.zig @@ -2,16 +2,12 @@ const std = @import("std"); const SDL = @import("sdl2"); const config = @import("../config.zig"); -const Bus = @import("Bus.zig"); const Scheduler = @import("scheduler.zig").Scheduler; const Arm7tdmi = @import("cpu.zig").Arm7tdmi; const FpsTracker = @import("../util.zig").FpsTracker; -const FilePaths = @import("../util.zig").FilePaths; const Timer = std.time.Timer; -const Thread = std.Thread; const Atomic = std.atomic.Atomic; -const Allocator = std.mem.Allocator; // 228 Lines which consist of 308 dots (which are 4 cycles long) const cycles_per_frame: u64 = 228 * (308 * 4); //280896 diff --git a/src/core/ppu.zig b/src/core/ppu.zig index 6315c4e..2d6072e 100644 --- a/src/core/ppu.zig +++ b/src/core/ppu.zig @@ -1,7 +1,6 @@ const std = @import("std"); const io = @import("bus/io.zig"); -const EventKind = @import("scheduler.zig").EventKind; const Scheduler = @import("scheduler.zig").Scheduler; const Arm7tdmi = @import("cpu.zig").Arm7tdmi; diff --git a/src/core/scheduler.zig b/src/core/scheduler.zig index e58c66e..57b847b 100644 --- a/src/core/scheduler.zig +++ b/src/core/scheduler.zig @@ -1,6 +1,5 @@ const std = @import("std"); -const Bus = @import("Bus.zig"); const Arm7tdmi = @import("cpu.zig").Arm7tdmi; const Clock = @import("bus/gpio.zig").Clock; diff --git a/src/platform.zig b/src/platform.zig index e8c2a2b..9d8e989 100644 --- a/src/platform.zig +++ b/src/platform.zig @@ -11,7 +11,6 @@ const FpsTracker = @import("util.zig").FpsTracker; const span = @import("util.zig").span; -const pitch = @import("core/ppu.zig").framebuf_pitch; const gba_width = @import("core/ppu.zig").width; const gba_height = @import("core/ppu.zig").height; @@ -269,11 +268,16 @@ const Audio = struct { want.callback = Self.callback; want.userdata = apu; + std.debug.assert(sample_format == SDL.AUDIO_F32); + log.info("Host Sample Rate: {}Hz, Host Format: SDL.AUDIO_F32", .{sample_rate}); + const device = SDL.SDL_OpenAudioDevice(null, 0, &want, &have, 0); if (device == 0) panic(); - if (!config.config().host.mute) + if (!config.config().host.mute) { SDL.SDL_PauseAudioDevice(device, 0); // Unpause Audio + log.info("Unpaused Device", .{}); + } return .{ .device = device }; }