[メモ] SION2 HDをWindowsローカルで

## 概要
- https://github.com/toyoshim/sion2hd からソース取得して、ビルド。ローカルでApache動かして、ゲームする。
- @toyoshimさんの記事[A ♪SOUND mind in a SOUND <body> : Z-MUSIC for the Web](http://qiita.com/toyoshim/items/38dafc97629a98434267)より、SION2HDにたどり着いた。

<!--
toyoshimさんのtwitterで紹介された模様
https://twitter.com/toyoshim/status/816575218017824768
-->

## 環境
- Windows 7 64bit
- ブラウザ
    - Firefox 50.1.0
    - Chrome 55.0.2883.87


## 手順

1. 必要なファイルのダウンロード・解凍・インストール
    - [git for Windows](https://git-for-windows.github.io/)<br>でふぉで`C:\Program Files\Git`
    - [emscripten:emsdk](https://kripken.github.io/emscripten-site/)<br>
=> Download and install the SDK => Portable Emscripten SDK for Windowsあたりから、`emsdk-1.35.0-portable-64bit.zip`をダウンロード<br>解凍先: `C:\emsdk\`
    - [GNU make](http://gnuwin32.sourceforge.net/packages/make.htm)<br>Binaries(make-3.81-bin.zip)とDependencies(make-3.81-dep.zip)をダウンロードして、bin内のファイルを取り出して、C:\emsdk\にコピー
        - `make.exe`
        - `libiconv2.dll`
        - `libintl3.dll`
    - [XAMPP](https://www.apachefriends.org/) <br>解凍先: `C:\xampp\`

2. cmd.exeをひらいて、以下コピペ。待つ。

    ```txt:以下こぴぺ
rem EMSDK
cd C:\emsdk\python\2*_64bit
copy python.exe python2.exe
cd C:\emsdk
set HOME=C:\emsdk
PATH=C:\Windows;C:\Windows\system32;C:\Program Files\Git\cmd;C:\Program Files\Git\usr\bin
emsdk.bat update
emsdk.bat install latest
emsdk.bat activate latest
emsdk_env.bat
rem XAMPP
cd C:\xampp\htdocs
git clone https://github.com/toyoshim/sion2hd.git
cd sion2hd
git submodule update --init --recursive
make
```

3. 実行
    1. `C:\xampp\xampp-control.exe` を実行、Apacheの\[Start\]をぽちっとする。<br>\# ポートが使われてたりすると、うまく起動しない
    2. Apache動作確認<br>ブラウザ開いて、`http://localhost/` にアクセスして XAMPP Apache + MariaDB + PHP + Perl　の文字が見えれば、おｋ<br>![Qiita-Sion2HD-01.png](https://qiita-image-store.s3.amazonaws.com/0/75594/3611efb7-eba1-d968-164c-7f1c7a8bc219.png)

    3. SION2HD<br>`http://localhost/sion2hd/www/` にアクセス
        - カーソルキーとZ、Xを使う??<br>![Qiita-Sion2HD-02_2.png](https://qiita-image-store.s3.amazonaws.com/0/75594/facae6fa-85f0-2a52-9dc2-cdd2e067715e.png)
        - ワイヤーフレーム かっこいい..<br>![Qiita-Sion2HD-03.png](https://qiita-image-store.s3.amazonaws.com/0/75594/11696ed1-8b35-f624-7db6-f83dea822d19.png)

<!--
![Qiita-Sion2HD-02.png](https://qiita-image-store.s3.amazonaws.com/0/75594/31b45162-6489-0b93-d1f1-66217512cc4e.png)
-->






## その他
- ちょいと説明
    - インストール後、emccを使うときは、以下のようなファイルを作っておいて、ダブルクリックする。

        ```bat:start_emsdk.cmd
set HOME=C:\emsdk
cd C:\emsdk
PATH=C:\Windows;C:\Windows\system32;C:\Program Files\Git\cmd;C:\Program Files\Git\usr\bin
rem 
cmd /k emsdk_env.bat
```
    - 初回の`emsdk.bat update`で、Errorとかでてあせるけど、気にせず、ほっとくこと。CTRL-Cとか押さない!
    - `PATH`はとりあえず、短く..
    - python2がないとおこられるので、emsdk付属のpython.exeを、python2.exeとして、コピーしてる。

- 実行例

```
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\>cd C:\emsdk\python\2*_64bit

C:\emsdk\python\2.7.5.3_64bit>copy python.exe python2.exe
        1 file(s) copied.

C:\emsdk\python\2.7.5.3_64bit>cd C:\emsdk

C:\emsdk>set HOME=C:\emsdk

C:\emsdk>PATH=C:\Windows;C:\Windows\system32;C:\Program Files\Git\cmd;C:\Program Files\Git\usr\bin

C:\emsdk>emsdk.bat update
Error parsing emsdk_manifest.json!
[Errno 2] No such file or directory: 'C:/emsdk/emsdk_manifest.json'
Downloading: C:/emsdk/zips/emsdk_windows_update.zip from https://s3.amazonaws.com/mozilla-games/emscripten/packages/emsdk_windows_update.zip
Unpacking 'C:/emsdk/zips/emsdk_windows_update.zip' to 'C:/emsdk'
Fetching all tags from Emscripten Github repository...
Done. 88 tagged releases available, latest is 1.37.1.

C:\emsdk>emsdk.bat install latest
Installing SDK 'sdk-1.35.0-64bit'..
Installing tool 'clang-e1.35.0-64bit'..
Downloading: C:/emsdk/zips/emscripten-clang_e1.35.0.zip from https://s3.amazonaws.com/mozilla-games/emscripten/packages/emscripten-clang_e1.35.0.zip
Unpacking 'C:/emsdk/zips/emscripten-clang_e1.35.0.zip' to 'C:/emsdk/clang/e1.35.0_64bit'
Done installing tool 'clang-e1.35.0-64bit'.
Installing tool 'node-4.1.1-64bit'..
Downloading: C:/emsdk/zips/node_4.1.1_64bit.zip from https://s3.amazonaws.com/mozilla-games/emscripten/packages/node_4.1.1_64bit.zip
Unpacking 'C:/emsdk/zips/node_4.1.1_64bit.zip' to 'C:/emsdk/node/4.1.1_64bit'
Done installing tool 'node-4.1.1-64bit'.
Installing tool 'python-2.7.5.3-64bit'..
The contents of file 'python_2.7.5.3_64bit.zip' already exist in destination 'C:/emsdk/python/2.7.5.3_64bit', skipping.
Done installing tool 'python-2.7.5.3-64bit'.
Installing tool 'emscripten-1.35.0'..
Downloading: C:/emsdk/zips/emscripten-1.35.0.zip from https://s3.amazonaws.com/mozilla-games/emscripten/packages/emscripten-1.35.0.zip
Unpacking 'C:/emsdk/zips/emscripten-1.35.0.zip' to 'C:/emsdk/emscripten/1.35.0'
Done installing tool 'emscripten-1.35.0'.
Done installing SDK 'sdk-1.35.0-64bit'.

C:\emsdk>emsdk.bat activate latest
Writing .emscripten configuration file to user home directory C:\emsdk/
The Emscripten configuration file C:\emsdk\.emscripten has been rewritten with the following contents:

import os
LLVM_ROOT='C:/emsdk/clang/e1.35.0_64bit'
EMSCRIPTEN_NATIVE_OPTIMIZER='C:/emsdk/clang/e1.35.0_64bit/optimizer.exe'
NODE_JS='C:/emsdk/node/4.1.1_64bit/bin/node'
PYTHON='C:/emsdk/python/2.7.5.3_64bit/python.exe'
EMSCRIPTEN_ROOT='C:/emsdk/emscripten/1.35.0'
SPIDERMONKEY_ENGINE = ''
V8_ENGINE = ''
TEMP_DIR = 'c:/users/mt08/appdata/local/temp'
COMPILER_ENGINE = NODE_JS
JS_ENGINES = [NODE_JS]

Adding directories to PATH:
PATH += C:\emsdk
PATH += C:\emsdk\clang\e1.35.0_64bit
PATH += C:\emsdk\node\4.1.1_64bit\bin
PATH += C:\emsdk\python\2.7.5.3_64bit
PATH += C:\emsdk\emscripten\1.35.0

To permanently register this environment globally to all users in Windows Registry, rerun the command with the option --global.

C:\emsdk>emsdk_env.bat

C:\emsdk>cd C:\xampp\htdocs

C:\xampp\htdocs>git clone https://github.com/toyoshim/sion2hd.git
Cloning into 'sion2hd'...
remote: Counting objects: 452, done.
Receiving objects:  82% (371/452)   0 (delta 0), pack-reused 452Receiving objects:  72% (326/452)
Receiving objects: 100% (452/452), 647.30 KiB | 0 bytes/s, done.
Resolving deltas: 100% (266/266), done.

C:\xampp\htdocs>cd sion2hd

C:\xampp\htdocs\sion2hd>git submodule update --init --recursive
Submodule 'third_party/magic2.js' (https://github.com/toyoshim/magic2.js.git) registered for path 'third_party/magic2.js'
Submodule 'third_party/z-music.js' (https://github.com/toyoshim/z-music.js.git) registered for path 'third_party/z-music.js'
Cloning into 'C:/xampp/htdocs/sion2hd/third_party/magic2.js'...
Cloning into 'C:/xampp/htdocs/sion2hd/third_party/z-music.js'...


Submodule 'third_party/X68Sound' (https://github.com/rururutan/X68Sound.git) registered for path 'third_party/z-music.js/third_party/X68Sound'
Submodule 'third_party/run68as' (https://github.com/toyoshim/run68as.git) registered for path 'third_party/z-music.js/third_party/run68as'
Cloning into 'C:/xampp/htdocs/sion2hd/third_party/z-music.js/third_party/X68Sound'...
Cloning into 'C:/xampp/htdocs/sion2hd/third_party/z-music.js/third_party/run68as'...


Submodule 'third_party/run68' (https://github.com/rururutan/run68.git) registered for path 'third_party/z-music.js/third_party/run68as/third_party/run68'
Cloning into 'C:/xampp/htdocs/sion2hd/third_party/z-music.js/third_party/run68as/third_party/run68'...
Submodule path 'third_party/z-music.js/third_party/run68as/third_party/run68': checked out '044630f2c475411167828822669c1f27d04406f9'

C:\xampp\htdocs\sion2hd>make
.
.
.
cp out/sion2.js www/sion2.js
cp out/sion2.data www/sion2.data
cp out/sion2.html.mem www/sion2.html.mem
cp third_party/z-music.js/dist/zmusic.js www/zmusic.js
cp third_party/magic2.js/magic2.js www/magic2.js

C:\xampp\htdocs\sion2hd>
```

- SMART BOMBER 2って、ラストステージ??