aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Veresov <aleksey@veresov.pro>2021-02-11 00:55:44 +0300
committerAleksey Veresov <aleksey@veresov.pro>2021-02-11 00:55:44 +0300
commit4b87e6879228a3491609254949c41a2405c29ad5 (patch)
tree81c13f2942bcfe2ef62aa3959f1d7fbf7ce626d1
parentdff4a3167f4b7cd13ee1d34b04a63f1f45a573ad (diff)
downloadsuem-4b87e6879228a3491609254949c41a2405c29ad5.tar
suem-4b87e6879228a3491609254949c41a2405c29ad5.tar.xz
suem-4b87e6879228a3491609254949c41a2405c29ad5.zip
Library test.
-rw-r--r--Main.hs32
-rw-r--r--package.yaml1
-rw-r--r--src/Suem.hs13
-rw-r--r--stack.yaml6
4 files changed, 43 insertions, 9 deletions
diff --git a/Main.hs b/Main.hs
index 48920a4..7b76428 100644
--- a/Main.hs
+++ b/Main.hs
@@ -1,6 +1,36 @@
module Main where
+import Options.Applicative
import Suem
+config :: Parser Config
+config = Config
+ <$> option auto
+ ( long "frequency"
+ <> short 'f'
+ <> metavar "HERTZ"
+ <> showDefault
+ <> value 8000000
+ <> help "Machine frequency in Hz" )
+ <*> option auto
+ ( long "ram"
+ <> short 'm'
+ <> metavar "RAM_SIZE"
+ <> showDefault
+ <> value (8 * 1024 * 1024)
+ <> help "Available RAM in bytes" )
+ <*> option auto
+ ( long "rom"
+ <> short 'r'
+ <> metavar "ROM_PATH"
+ <> showDefault
+ <> value "rom.bin"
+ <> help "Path to file to load into ROM" )
+
main :: IO ()
-main = printROM
+main = suem =<< execParser opts
+ where
+ opts = info (config <**> helper)
+ ( fullDesc
+ <> progDesc "Emulator of Suen, machine on M68000"
+ <> header "suem - Suen emulator" )
diff --git a/package.yaml b/package.yaml
index af4a48e..546eed6 100644
--- a/package.yaml
+++ b/package.yaml
@@ -19,3 +19,4 @@ executable:
ghc-options: -threaded -rtsopts -with-rtsopts=-N
dependencies:
- suem
+ - optparse-applicative
diff --git a/src/Suem.hs b/src/Suem.hs
index f74976e..bbdfa78 100644
--- a/src/Suem.hs
+++ b/src/Suem.hs
@@ -1,4 +1,11 @@
-module Suem (printROM) where
+module Suem (Config(..), suem) where
-printROM :: IO ()
-printROM = putStrLn "ROM"
+data Config = Config {
+ freq :: Int,
+ ram :: Int,
+ rom :: String
+}
+
+suem :: Config -> IO ()
+suem (Config _ _ r) = putStrLn $ "Loaded " ++ r ++ " into ROM."
+suem _ = return ()
diff --git a/stack.yaml b/stack.yaml
index eb28bf4..d5cd0ae 100644
--- a/stack.yaml
+++ b/stack.yaml
@@ -1,8 +1,4 @@
packages:
- .
system-ghc: true
-resolver:
- compiler: ghc-8.8.4
-extra-deps:
-- vector-0.12.2.0
-- network-3.1.2.1
+resolver: lts-16.21