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 { Options {
screenScaleX = 5, screenScale = (5, 3),
screenScaleY = 3,
topOverscan = 10, topOverscan = 10,
bottomOverscan = 10, bottomOverscan = 10,
motionBlurAlpha = 1.0, motionBlurAlpha = 1.0,

View file

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

View file

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

View file

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

View file

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