Skip to content

Commit

Permalink
Use explicit import lists
Browse files Browse the repository at this point in the history
  • Loading branch information
CLowcay committed Jan 29, 2021
1 parent ed51fa6 commit 3cf0fe2
Show file tree
Hide file tree
Showing 78 changed files with 1,130 additions and 1,121 deletions.
32 changes: 16 additions & 16 deletions core/src/Machine/GBC/Audio.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ module Machine.GBC.Audio
)
where

import Control.Monad.Reader
import Data.Bifunctor
import Data.Bits
import Data.Functor
import Data.Word
import Machine.GBC.Audio.Common
import Machine.GBC.Audio.NoiseChannel
import Machine.GBC.Audio.PulseChannel
import Machine.GBC.Audio.WaveChannel
import Control.Monad.Reader (void, when)
import Data.Bifunctor (Bifunctor (first))
import Data.Bits (Bits (testBit, (.&.), (.|.)))
import Data.Functor ((<&>))
import Data.Word (Word16, Word8)
import Machine.GBC.Audio.Common (Channel (..), FrameSequencerOutput (..), flagChannel1Enable, flagChannel2Enable, flagMasterPower, newAudioPort)
import Machine.GBC.Audio.NoiseChannel (NoiseChannel, newNoiseChannel)
import Machine.GBC.Audio.PulseChannel (PulseChannel, newPulseChannel)
import Machine.GBC.Audio.WaveChannel (WaveChannel, newWaveChannel)
import Machine.GBC.Primitive
import Machine.GBC.Registers
import Machine.GBC.Util
import qualified Machine.GBC.Registers as R
import Machine.GBC.Util (isFlagSet, (.<<.), (.>>.))
import Prelude hiding (init)

data State = State
Expand Down Expand Up @@ -79,16 +79,16 @@ init = mdo

ports :: State -> [(Word16, Port)]
ports State {..} =
[(NR50, port50), (NR51, port51), (NR52, port52), (PCM12, portPCM12), (PCM34, portPCM34)]
[(R.NR50, port50), (R.NR51, port51), (R.NR52, port52), (R.PCM12, portPCM12), (R.PCM34, portPCM34)]
++ channel1Ports
++ channel2Ports
++ channel3Ports
++ channel4Ports
where
channel1Ports = first ((+ NR10) . fromIntegral) <$> getPorts channel1
channel2Ports = first ((+ NR20) . fromIntegral) <$> getPorts channel2
channel3Ports = first ((+ NR30) . fromIntegral) <$> getPorts channel3
channel4Ports = first ((+ NR40) . fromIntegral) <$> getPorts channel4
channel1Ports = first ((+ R.NR10) . fromIntegral) <$> getPorts channel1
channel2Ports = first ((+ R.NR20) . fromIntegral) <$> getPorts channel2
channel3Ports = first ((+ R.NR30) . fromIntegral) <$> getPorts channel3
channel4Ports = first ((+ R.NR40) . fromIntegral) <$> getPorts channel4

samplePeriod :: Int
samplePeriod = 94
Expand Down
6 changes: 3 additions & 3 deletions core/src/Machine/GBC/Audio/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ module Machine.GBC.Audio.Common
)
where

import Data.Bits
import Data.Word
import Data.Bits (Bits (..))
import Data.Word (Word8)
import Machine.GBC.Primitive
import Machine.GBC.Util
import Machine.GBC.Util (isFlagSet, (.<<.))

flagTrigger, flagLength :: Word8
flagTrigger = 0x80
Expand Down
12 changes: 6 additions & 6 deletions core/src/Machine/GBC/Audio/Envelope.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ module Machine.GBC.Audio.Envelope
)
where

import Control.Monad
import Data.Bits
import Data.Word
import Machine.GBC.Audio.Common
import Control.Monad (unless)
import Data.Bits (Bits (..))
import Data.Word (Word8)
import Machine.GBC.Audio.Common (FrameSequencerOutput, nextStepWillClockEnvelope)
import Machine.GBC.Primitive
import Machine.GBC.Primitive.UnboxedRef
import Machine.GBC.Util
import Machine.GBC.Primitive.UnboxedRef (UnboxedRef, newUnboxedRef, readUnboxedRef, writeUnboxedRef)
import Machine.GBC.Util (isFlagSet, (.>>.))

data Envelope = Envelope
{ volumeRef :: !(UnboxedRef Int),
Expand Down
12 changes: 6 additions & 6 deletions core/src/Machine/GBC/Audio/Length.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ module Machine.GBC.Audio.Length
)
where

import Control.Monad
import Data.Bits
import Data.IORef
import Data.Word
import Machine.GBC.Audio.Common
import Control.Monad (unless, when)
import Data.Bits (Bits (..))
import Data.IORef (IORef, newIORef, readIORef, writeIORef)
import Data.Word (Word8)
import Machine.GBC.Audio.Common (FrameSequencerOutput, lastStepClockedLength)
import Machine.GBC.Primitive

data Length = Length
Expand All @@ -42,7 +42,7 @@ initLength Length {..} frameSequencer enabled = do
-- Quirk: If we are enabling the length counter, and it is currently 0, and
-- the last frame sequencer step clocked the length, then clock the length
-- again.
when (enabled && (lastStepClockedLength frameSequencer) && v == 0) $
when (enabled && lastStepClockedLength frameSequencer && v == 0) $
updateCounter counter 1 (pure 0)

powerOffLength :: Length -> IO ()
Expand Down
18 changes: 9 additions & 9 deletions core/src/Machine/GBC/Audio/NoiseChannel.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

module Machine.GBC.Audio.NoiseChannel where

import Control.Monad.Reader
import Data.Bits
import Data.IORef
import Data.Word
import Machine.GBC.Audio.Common
import Machine.GBC.Audio.Envelope
import Machine.GBC.Audio.Length
import Control.Monad.Reader (unless, when)
import Data.Bits (Bits (testBit, (.&.)))
import Data.IORef (IORef, newIORef, readIORef, writeIORef)
import Data.Word (Word16, Word8)
import Machine.GBC.Audio.Common (Channel (..), FrameSequencerOutput, flagChannel4Enable, flagLength, flagTrigger, isEnvelopeClockingStep, isLengthClockingStep, newAudioPortWithReadMask, updateStatus)
import Machine.GBC.Audio.Envelope (Envelope, clockEnvelope, envelopeVolume, initEnvelope, newEnvelope)
import Machine.GBC.Audio.Length (Length, clockLength, extraClocks, initLength, newLength, powerOffLength, reloadLength)
import Machine.GBC.Primitive
import Machine.GBC.Primitive.UnboxedRef
import Machine.GBC.Util
import Machine.GBC.Primitive.UnboxedRef (UnboxedRef, newUnboxedRef, readUnboxedRef, writeUnboxedRef)
import Machine.GBC.Util (isFlagSet, (.<<.), (.>>.))

data NoiseChannel = NoiseChannel
{ enable :: !(IORef Bool),
Expand Down
20 changes: 10 additions & 10 deletions core/src/Machine/GBC/Audio/PulseChannel.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ module Machine.GBC.Audio.PulseChannel
)
where

import Control.Monad.Reader
import Data.Bits
import Data.IORef
import Data.Word
import Machine.GBC.Audio.Common
import Machine.GBC.Audio.Envelope
import Machine.GBC.Audio.Length
import Machine.GBC.Audio.Sweep
import Control.Monad.Reader (unless, when)
import Data.Bits (Bits (complement, (.&.), (.|.)))
import Data.IORef (IORef, newIORef, readIORef, writeIORef)
import Data.Word (Word8)
import Machine.GBC.Audio.Common (Channel (..), FrameSequencerOutput, flagLength, flagTrigger, getFrequency, isEnvelopeClockingStep, isLengthClockingStep, isSweepClockingStep, newAudioPort, newAudioPortWithReadMask, updateStatus)
import Machine.GBC.Audio.Envelope (Envelope, clockEnvelope, envelopeVolume, initEnvelope, newEnvelope)
import Machine.GBC.Audio.Length (Length, clockLength, extraClocks, initLength, newLength, powerOffLength, reloadLength)
import Machine.GBC.Audio.Sweep (Sweep, clockSweep, flagNegate, hasPerformedSweepCalculationInNegateMode, initSweep, newSweep)
import Machine.GBC.Primitive
import Machine.GBC.Primitive.UnboxedRef
import Machine.GBC.Util
import Machine.GBC.Primitive.UnboxedRef (UnboxedRef, newUnboxedRef, readUnboxedRef, writeUnboxedRef)
import Machine.GBC.Util (isFlagSet, (.>>.))

data PulseChannel = PulseChannel
{ output :: !(UnboxedRef Int),
Expand Down
14 changes: 7 additions & 7 deletions core/src/Machine/GBC/Audio/Sweep.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ module Machine.GBC.Audio.Sweep
)
where

import Control.Monad
import Data.Bits
import Data.IORef
import Data.Word
import Machine.GBC.Audio.Common
import Control.Monad (void, when)
import Data.Bits (Bits ((.&.)))
import Data.IORef (IORef, newIORef, readIORef, writeIORef)
import Data.Word (Word8)
import Machine.GBC.Audio.Common (updateFrequency)
import Machine.GBC.Primitive
import Machine.GBC.Primitive.UnboxedRef
import Machine.GBC.Util
import Machine.GBC.Primitive.UnboxedRef (UnboxedRef, newUnboxedRef, readUnboxedRef, writeUnboxedRef)
import Machine.GBC.Util (isFlagSet, (.>>.))

data Sweep = Sweep
{ enable :: !(IORef Bool),
Expand Down
18 changes: 9 additions & 9 deletions core/src/Machine/GBC/Audio/WaveChannel.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ module Machine.GBC.Audio.WaveChannel
)
where

import Control.Monad.Reader
import Data.Bits
import Data.Foldable
import Data.IORef
import Control.Monad.Reader (unless, when)
import Data.Bits (Bits ((.&.)))
import Data.Foldable (Foldable (toList))
import Data.IORef (IORef, newIORef, readIORef, writeIORef)
import qualified Data.Vector as V
import Data.Word
import Machine.GBC.Audio.Common
import Machine.GBC.Audio.Length
import Data.Word (Word8)
import Machine.GBC.Audio.Common (Channel (..), FrameSequencerOutput, flagChannel3Enable, flagLength, flagTrigger, getFrequency, isLengthClockingStep, newAudioPortWithReadMask, updateStatus)
import Machine.GBC.Audio.Length (Length, clockLength, extraClocks, initLength, newLength, powerOffLength, reloadLength)
import Machine.GBC.Primitive
import Machine.GBC.Primitive.UnboxedRef
import Machine.GBC.Util
import Machine.GBC.Primitive.UnboxedRef (UnboxedRef, newUnboxedRef, readUnboxedRef, writeUnboxedRef)
import Machine.GBC.Util (isFlagSet, (.>>.))

data WaveChannel = WaveChannel
{ output :: !(UnboxedRef Int),
Expand Down
4 changes: 2 additions & 2 deletions core/src/Machine/GBC/Bus.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module Machine.GBC.Bus
)
where

import Control.Monad.Reader
import Data.Word
import Control.Monad.Reader (ReaderT)
import Data.Word (Word16, Word8)

class Has env where
-- | Do one read cycle.
Expand Down
Loading

0 comments on commit 3cf0fe2

Please sign in to comment.