1.准备代码:
https://github.com/mamedev/mame
下载 name的源码
https://github.com/db48x/emularity
下载 emularity 为h5端的内容
把mame的代码 ln -s 到
emularity/emulators/mame下
2.准备游戏的rom:
网上搜到变身忍者 的rom 为shadfrce.zip
战国之刃2的rom为 tengai.zip
放到emularity/emulators/roms里
3.安装emscripten:
验证emcc可用,需要用到emmake
4.编译
进入mame目录:
战国之刃是彩京到作品,
编译
emmake make SUBTARGET=psikyo SOURCES=src/mame/drivers/psikyo.cpp
编译之后得到
mamepsikyo.js
mamepsikyo.wasm
psikyo.bc
三个文件
5.使用wasm
基础支持参考《Learn Webassembly》那本书的第八章,
原理就是wasm能把sdl和h5结合起来:
只通过1行代码
var Module = {
canvas: (function() {
return document.getElementById('canvas'); })()
};
利用canvas解决sdl的对应问题
具体参考https://github.com/timhutton/sdl-canvas-wasm
mame有sdl的实现方式,所以mame就能放到h5上了
在h5模拟器emularity下
修改example_arcade.html ,这个是mame模拟器的h5版本
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>example arcade game</title>
</head>
<body>
<canvas id="canvas" style="width: 50%; height: 50%; display: block; margin: 0 auto;"></canvas>
<script type="text/javascript" src="es6-promise.js
263



被折叠的 条评论
为什么被折叠?



