summaryrefslogtreecommitdiff
path: root/fig-emulator-gb/main/Main.hs
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2025-06-01 19:07:25 -0400
committerLLLL Colonq <llll@colonq>2025-06-01 19:07:25 -0400
commit4bc8bd58e6f9a6ca509d4e6869ba10c65145775d (patch)
tree5bc97cc01e737f9cacba1f7c13570ce7846acf36 /fig-emulator-gb/main/Main.hs
parentf95d9bbde51ee26468177b2d34c669d9689fbea4 (diff)
Remove fig-emulator-gb
Diffstat (limited to 'fig-emulator-gb/main/Main.hs')
-rw-r--r--fig-emulator-gb/main/Main.hs71
1 files changed, 0 insertions, 71 deletions
diff --git a/fig-emulator-gb/main/Main.hs b/fig-emulator-gb/main/Main.hs
deleted file mode 100644
index 6284c6a..0000000
--- a/fig-emulator-gb/main/Main.hs
+++ /dev/null
@@ -1,71 +0,0 @@
-{-# Language ApplicativeDo #-}
-
-module Main where
-
-import Fig.Prelude
-
-import qualified System.Directory as Dir
-
-import Options.Applicative
-
-import Control.Monad (unless)
-
-import Control.Exception.Safe (Handler(..), catches)
-
-import qualified Data.ByteString as BS
-
-import Fig.Emulator.GB
-import Fig.Emulator.GB.Test.Instr
-
-data RunOptions = RunOptions
- { romPath :: !FilePath
- , serialOut :: !(Maybe FilePath)
- } deriving Show
-
-parseRunOptions :: Parser RunOptions
-parseRunOptions = do
- romPath <- argument str (metavar "PATH")
- serialOut <- optional $ strOption (long "serial" <> metavar "PATH" <> help "Path to write link cable serial output")
- pure RunOptions{..}
-
-newtype InstrTestOptions = InstrTestOptions
- { testcasesPath :: FilePath
- } deriving Show
-
-parseInstrTestOptions :: Parser InstrTestOptions
-parseInstrTestOptions = do
- testcasesPath <- argument str (metavar "PATH")
- pure InstrTestOptions{..}
-
-data Command
- = CommandRun !RunOptions
- | CommandInstrTest !InstrTestOptions
- deriving Show
-
-parseOptions :: Parser Command
-parseOptions = subparser $ mconcat
- [ command "run" $ info (CommandRun <$> parseRunOptions) (progDesc "Emulate a ROM file")
- , command "instr-test" $ info (CommandInstrTest <$> parseInstrTestOptions) (progDesc "Run CPU testcases")
- ]
-
-main :: IO ()
-main = do
- cmd <- execParser $ info (parseOptions <**> helper)
- ( fullDesc
- <> header "fig-emulator-gb - Game Boy emulator"
- )
- case cmd of
- CommandRun opts -> do
- rom <- BS.readFile $ romPath opts
- testRun (serialOut opts) rom
- CommandInstrTest opts -> catches
- ( do
- paths <- Dir.listDirectory $ testcasesPath opts
- forM_ paths \p -> do
- unless (p == "README.md") do
- hPutStrLn stderr $ "Running test file: " <> pack p <> "..."
- tcs <- readTestcases $ testcasesPath opts <> "/" <> p
- forM_ tcs runTestcase
- )
- [ Handler \(e :: InstrTestError) -> liftIO . hPutStrLn stderr $ pretty e
- ]