Pixel Pedals of Tomakomai

北海道苫小牧市出身の初老の日常

monadiusを動かす

12年前に書かれた http://www.geocities.jp/takascience/haskell/monadius_ja.html を手元で動かした。と言っても、ほぼ手を加えずにそのまま動いた。

$ diff -ur monadius.BK/ monadius
diff -ur monadius.BK/src/Main.hs monadius/src/Main.hs
--- monadius.BK/src/Main.hs     2017-05-16 08:02:04.566956400 +0900
+++ monadius/src/Main.hs        2017-05-16 08:08:18.524217900 +0900
@@ -49,7 +49,8 @@
 loadReplay::String-> IO ReplayInfo
 loadReplay filename = readFile filename >>= (return.read)

-main = withMusic $ do
+main = withMusic $ do
+  getArgsAndInitialize
   args <-getArgs
   putDebugStrLn $ show args

@@ -109,7 +110,7 @@
   mainLoop
   destroyWindow curwnd

-  `catch` (\exc -> return ())
+  `catch` (\exc -> print (exc :: SomeException))

   where
   getReplayFilename args = if length candidates == 0 then Nothing else Just (head candidates) where
@@ -119,7 +120,7 @@
   removesuffix str = if '.' `elem` str then (removesuffix.init) str else str

 exitLoop = do
-  throwIO $ ExitException ExitSuccess
+  exitWith ExitSuccess

 initMatrix = do
   viewport $= (Position 0 0,Size 640 480)
@@ -375,9 +376,9 @@

 closeProc = do
   putDebugStrLn "closed"
-  throwIO $ ExitException ExitSuccess
+  exitWith ExitSuccess


 savePoints = [0,1280,3000,6080]

-
\ No newline at end of file
+

diff -ur monadius.BK/src/Monadius.hs monadius/src/Monadius.hs
--- monadius.BK/src/Monadius.hs 2017-05-16 08:02:04.582583000 +0900
+++ monadius/src/Monadius.hs    2017-05-16 08:02:24.097737300 +0900
@@ -5,7 +5,7 @@
   shotButton,missileButton,powerUpButton,upButton,downButton,leftButton,rightButton,selfDestructButton
 )where

-import Graphics.UI.GLUT hiding (position)
+import Graphics.UI.GLUT hiding (position, DebugMessage)
 import Graphics.Rendering.OpenGL.GLU
 import Control.Exception
 import Control.Monad

freeglut導入済みのmingw64でビルド。Windows上でビルドしたので音も出る。Cのコードも入っているので注意。

$ cd src
$ stack exec makefile.bat

と、これで動いたのだけど、5年前に自分で作ったパッチ を見ると、 (_, args) <- getArgsAndInitialize とするのが正しいらしい。まあいいや。

ちなみに、 Surface Book 上で動かしているのだけど、微妙に動きに引っかかりを感じる。引っかかる程度でほぼなめらかには動いているのだけど。

2017/5/18追記: hackageにも上がってた