Refactored init

This commit is contained in:
Dan Piponi 2019-09-01 16:27:00 -07:00
parent ac1764c923
commit a57a64ba06
5 changed files with 13 additions and 17 deletions

View file

@ -1,6 +1,5 @@
Options {
screenScaleX = 5,
screenScaleY = 3,
screenScale = (5, 3),
topOverscan = 10,
bottomOverscan = 10,
motionBlurAlpha = 1.0,

View file

@ -120,6 +120,7 @@ delayList = [
#endif
]
loopEmulation :: AtariKeys -> IORef (BankersDequeue UIKey) -> MonadAtari b
loopEmulation atariKeys queueRef = do
liftIO pollEvents
queue <- liftIO $ readIORef queueRef
@ -150,10 +151,9 @@ startingState args' options' window = do
let initBankState = initialBankState bankStyle'
print $ "Initial bank state = " ++ show initBankState
let screenScaleX' = screenScaleX options'
let screenScaleY' = screenScaleY options'
initState screenScaleX' screenScaleY'
(screenWidth*screenScaleX') (screenHeight*screenScaleY')
let screenScale' = screenScale options'
initState screenScale'
(screenWidth*fst screenScale') (screenHeight*snd screenScale')
ramArray
#if TRACE
recordArray
@ -173,15 +173,14 @@ main = do
optionsString <- readFile optionsFile
let options' = read optionsString :: Options
print options'
let screenScaleX' = screenScaleX options'
let screenScaleY' = screenScaleY options'
let screenScale' = screenScale options'
-- XXX Make list of default keys
let Just atariKeys = keysFromOptions options'
rc <- init -- init video
when (not rc) $ die "Couldn't init graphics"
queueRef <- newIORef empty
window <- makeMainWindow screenScaleX' screenScaleY' queueRef
window <- makeMainWindow screenScale' queueRef
state <- startingState args' options' window

View file

@ -202,8 +202,8 @@ vertices = V.fromList [ -1.0, -1.0
, -1.0, 1.0
]
makeMainWindow :: Int -> Int -> IORef (BankersDequeue UIKey) -> IO Window
makeMainWindow screenScaleX' screenScaleY' queue = do
makeMainWindow :: (Int, Int) -> IORef (BankersDequeue UIKey) -> IO Window
makeMainWindow (screenScaleX', screenScaleY') queue = do
windowHint (WindowHint'OpenGLProfile OpenGLProfile'Any)
windowHint (WindowHint'DoubleBuffer True)

View file

@ -651,7 +651,7 @@ makeDelayArray delayList = do
forM_ delayList $ \(addr, d) -> writeArray delayArray addr d
return delayArray
initState :: Int -> Int -> Int -> Int ->
initState :: (Int, Int) -> Int -> Int ->
IOUArray Int Word8 ->
#if TRACE
StorableArray Int Word8 ->
@ -669,7 +669,7 @@ initState :: Int -> Int -> Int -> Int ->
[(Word16, Int)] ->
Controllers ->
IO Atari2600
initState xscale' yscale' width height ram'
initState (xscale', yscale') width height ram'
#if TRACE
record'
#endif

View file

@ -182,8 +182,7 @@ scancodeFromString :: String -> Maybe Key
scancodeFromString name = lookup name keyNames
data Options = Options {
screenScaleX :: Int,
screenScaleY :: Int,
screenScale :: (Int, Int),
topOverscan :: Int,
bottomOverscan :: Int,
motionBlurAlpha :: Float,
@ -240,8 +239,7 @@ data Options = Options {
defaultOptions :: Options
defaultOptions = Options {
screenScaleX = 5,
screenScaleY = 3,
screenScale = (5, 3),
topOverscan = 10,
bottomOverscan = 10,
motionBlurAlpha = 1.0,