FC游戏站:为您提供一个绿色免费的下载空间! 首页| 电脑软件| 安卓 | 手机网站
当前位置:首页 > FC游戏动态 > 打造S3C6410 的超级游戏机 (2)

打造S3C6410 的超级游戏机 (2)

来源:FC游戏站 更新:2020-11-22

用手机看

扫描二维码随时看1.在手机上浏览
2.分享给你的微信好友或朋友圈

在解决硬件缩放问题后,我先移植了Dosbox ,这样很多经典的DOS游戏可以直接在板上运行.


随后我开始的对于红白机模拟器的的移植.这是任天堂出的经典游戏机,小时候隔壁小孩子有一台,多数时间只能眼巴巴看着打,不过现在有得打,倒没有时间和心情玩这个了.


 首先网上有70多MB的500合一的ROM下载.先到这里下载.压缩包里自带WINDOWS的下简单模拟器.

 可以从这里下载

  

  ?UrlID=1&SoftID=25355



我手头有三个红白机模拟器, fceux,dgen,Nestopia ,测试一下fceux和Nestopia的WINDOWS版,可以运行ROM,而Dgen在LINUX很容易移植,但是无法运行ROM,因此放弃了.因为先下到是fceux的源码,因此先移植这个版本

  


 


一.安装scons 

    

   fecux 新版的构造工具使用scons,而不是传统的make.一般的Linux没有安装这个工具,需要从网上下载源码安装.

  scons是用python语言编写的,因此确保你的机器安装Python的解释器.

  下载:

     

    它是从 

  

  安装

     它从其它的基于python的工具安装方法一样,也是用一个Pythone脚本来安装的

    解压后在源码目录运行如下命令即可安装

         python setup.py install


  使用

     scons的使用类似于make,但是他的构造脚本名字不是Makefile,名字是SConstruct.

    因此如果当前目录下有SConstruct 文件,直接运行 scons 即可


 二 fceux X86版的移植

  

  1.解压源码

    从官网下载 

   最新源码是 2.1.5

      %20Code/2.1.5%20src/fceux-2.1.5.src.tar.bz2/download

 2.修改编译选项

  

  缺省的fceux是需要GTK库的,主要是显示菜单,但是在嵌入式里移植GTK还是比较麻烦,而且命令行也能达到同样效果,因此要修改构造文件SConstruct,关闭GTK支持.

  将SConstruct 中如下句子修改

   BoolVariable('GTK', 'Enable GTK2 GUI (SDL only)', 1),

  修改成

   BoolVariable('GTK', 'Enable GTK2 GUI (SDL only)', 0),

   

 3.编译

   直接在源码目录运行

     scons 


  清除编译结果

    scons -c  #类似于make clean


   如果提示如下,说明没有安装GTK库,可以按第2步关掉GTK的支持

   

src/drivers/sdl/../../utils/xstring.h:131:45: warning: no newline at end of file

src/drivers/sdl/input.cpp: In function 'std::string GetUserText(const char*)':

src/drivers/sdl/input.cpp:284: error: 'gtk_dialog_get_content_area' was not declared in this scope

src/drivers/sdl/input.cpp: In function 'int ButtonConfigBegin()':

src/drivers/sdl/input.cpp:802: error: 'gtk_widget_get_window' was not declared in this scope

src/drivers/sdl/input.cpp: In function 'void ButtonConfigEnd()':

src/drivers/sdl/input.cpp:833: warning: unused variable 'GameInfo'

src/drivers/sdl/sdl-video.h: At global scope:

src/drivers/sdl/sdl-video.h:6: warning: 's_screen' defined but not used

src/drivers/sdl/sdl.h:9: warning: 'void DoFun(int)' declared 'static' but never defined


4.安装.

  运行源码的目录的安装脚本

    install.sh 


5.运行

  因为没有图形界面,直接用命令行参数指明ROM文件路径

  可以是nes或zip格式


   fceux yourrom.nes

  这是实际运行效果

   

 

三 fceux ARM版的移植


fceux提供一个脚本来演示怎么移植,debian-crossbuild.sh.主要是设环境变量。

#!/bin/sh

if [ -f /usr/bin/i586-mingw32msvc-windres ]; then HOST=i586-mingw32msvc

else HOST=i586-mingw32

fi

PLATFORM=win32 CC=${HOST}-gcc CXX=${HOST}-g++ WRC=${HOST}-windres WINDRES=${HOST}-windres scons $@

  后来经过几次编译尝试后,最终我使用的脚本arm-linux.sh内容如下


PLATFORM=posix CC=http://blog.chinaunix.net/usr/local/arm/4.4.1/bin/arm-linux-gcc CXX=http://blog.chinaunix.net/usr/local/arm/4.4.1/bin/arm-linux-g++ LDFLAGS="-L/home/huisen/workspace/output/arm-linux/lib -lSDL -lz -liconv -lts" scons $@

这里注意要使用绝对路径,好象Shell的PWD,PATH环境变量没有生效,,FC,因此这里使绝对路径。


这里scons的构造文件也要大量修改。我编译成功的文件内容如下,红字是改动过的

import os

import sys

import platform

opts = Variables()

opts.AddVariables(

BoolVariable('FRAMESKIP', 'Enable frameskipping', 1),

BoolVariable('OPENGL', 'Enable OpenGL support', 1),

BoolVariable('LSB_FIRST', 'Least signficant byte first (non-PPC)', 1),

BoolVariable('DEBUG', 'Build with debugging symbols', 0),

BoolVariable('LUA', 'Enable Lua support', 1),

BoolVariable('NEWPPU', 'Enable new PPU core', 1),

BoolVariable('CREATE_AVI', 'Enable avi creation support (SDL only)', 1),

BoolVariable('LOGO', 'Enable a logoscreen when creating avis (SDL only)', '1'),

BoolVariable('GTK', 'Enable GTK2 GUI (SDL only)', 0),

BoolVariable('GTK3', 'Enable GTK3 GUI (BROKEN/EXPERIMENTAL)', 0),

)

env = Environment(options = opts)

env.Append(CPPDEFINES=["PUBLIC_RELEASE"])

# LSB_FIRST must be off for PPC to compile

if platform.system == "ppc":

env['LSB_FIRST'] = 0

# Default compiler flags:

env.Append(CCFLAGS = ['-I/home/huisen/workspace/output/arm-linux/include/SDL','-Wall', '-Wno-write-strings', '-Wno-sign-compare', '-O2', '-Isrc/lua/src','-DHAVE_ASPRINTF'])

if os.environ.has_key('PLATFORM'):

env.Replace(PLATFORM = os.environ['PLATFORM'])

if os.environ.has_key('CC'):

env.Replace(CC = os.environ['CC'])

if os.environ.has_key('CXX'):

env.Replace(CXX = os.environ['CXX'])

if os.environ.has_key('WINDRES'):

env.Replace(WINDRES = os.environ['WINDRES'])

if os.environ.has_key('CFLAGS'):

env.Append(CCFLAGS = os.environ['CFLAGS'].split())

if os.environ.has_key('LDFLAGS'):

env.Append(LINKFLAGS = os.environ['LDFLAGS'].split())

print "platform: ", env['PLATFORM']

# special flags for cygwin

# we have to do this here so that the function and lib checks will go through mingw

if env['PLATFORM'] == 'cygwin':

env.Append(CCFLAGS = " -mno-cygwin")

env.Append(LINKFLAGS = " -mno-cygwin")

env['LIBS'] = ['wsock32'];

if env['PLATFORM'] == 'win32':

env.Append(CPPPATH = [".", "drivers/win/", "drivers/common/", "drivers/", "drivers/win/zlib", "drivers/win/directx", "drivers/win/lua/include"])

env.Append(CPPDEFINES = ["PSS_STYLE=2", "WIN32", "_USE_SHARED_MEMORY_", "NETWORK", "FCEUDEF_DEBUGGER", "NOMINMAX", "NEED_MINGW_HACKS", "_WIN32_IE=0x0600"])

env.Append(LIBS = ["rpcrt4", "comctl32", "vfw32", "winmm", "ws2_32", "comdlg32", "ole32", "gdi32", "htmlhelp"])

else:

conf = Configure(env)

#assert conf.CheckLibWithHeader('z', 'zlib.h', 'C', 'inflate;', 1), "please install: zlib"

if not conf.CheckLib('SDL'):

print 'Did not find libSDL or SDL.lib, exiting!'

#Exit(1)

if env['GTK']:

# Add compiler and linker flags from pkg-config

env.ParseConfig('pkg-config --cflags --libs gtk+-2.0')

env.Append(CPPDEFINES=["_GTK2"])

env.Append(CCFLAGS = ["-D_GTK"])

if env['GTK3']:

# Add compiler and linker flags from pkg-config

env.ParseConfig('pkg-config --cflags --libs gtk+-3.0')

env.Append(CPPDEFINES=["_GTK3"])

env.Append(CCFLAGS = ["-D_GTK"])

### Lua platform defines

### Applies to all files even though only lua needs it, but should be ok

if env['LUA']:

env.Append(CPPDEFINES=["_S9XLUA_H"])

if env['PLATFORM'] == 'darwin':

# Define LUA_USE_MACOSX otherwise we can't bind external libs from lua

env.Append(CCFLAGS = ["-DLUA_USE_MACOSX"])

if env['PLATFORM'] == 'posix':

# If we're POSIX, we use LUA_USE_LINUX since that combines usual lua posix defines with dlfcn calls for dynamic library loading.

# Should work on any *nix

env.Append(CCFLAGS = ["-DLUA_USE_LINUX"])

### Search for gd if we're not in Windows

if env['PLATFORM'] != 'win32' and env['PLATFORM'] != 'cygwin' and env['CREATE_AVI'] and env['LOGO']:

gd = conf.CheckLib('gd', autoadd=1)

if gd == 0:

env['LOGO'] = 0

print 'Did not find libgd, you won't be able to create a logo screen for your avis.'

if conf.CheckFunc('asprintf'):

conf.env.Append(CCFLAGS = "-DHAVE_ASPRINTF")

if env['OPENGL'] and conf.CheckLibWithHeader('GL', 'GL/gl.h', 'c++', autoadd=1):

conf.env.Append(CCFLAGS = "-DOPENGL")

conf.env.Append(CPPDEFINES = ['PSS_STYLE=1'])

# parse SDL cflags/libs

#env.ParseConfig('sdl-config --cflags --libs')

env = conf.Finish()

if sys.byteorder == 'little' or env['PLATFORM'] == 'win32':

env.Append(CPPDEFINES = ['LSB_FIRST'])

if env['FRAMESKIP']:

env.Append(CPPDEFINES = ['FRAMESKIP'])

print "base CPPDEFINES:",env['CPPDEFINES']

print "base CCFLAGS:",env['CCFLAGS']

if env['DEBUG']:

env.Append(CPPDEFINES=["_DEBUG"], CCFLAGS = ['-g'])

if env['PLATFORM'] != 'win32' and env['PLATFORM'] != 'cygwin' and env['CREATE_AVI']:

env.Append(CPPDEFINES=["CREATE_AVI"])

else:

env['CREATE_AVI']=0;

Export('env')

SConscript('src/SConscript')

# Install rules

exe_suffix = ''

if env['PLATFORM'] == 'win32':

exe_suffix = '.exe'

fceux_src = 'src/fceux' + exe_suffix

fceux_dst = 'bin/fceux' + exe_suffix

auxlib_src = 'src/auxlib.lua'

auxlib_dst = 'bin/auxlib.lua'

fceux_h_src = 'src/drivers/win/help/fceux.chm'

fceux_h_dst = 'bin/fceux.chm'

env.Command(fceux_h_dst, fceux_h_src, [Copy(fceux_h_dst, fceux_h_src)])

env.Command(fceux_dst, fceux_src, [Copy(fceux_dst, fceux_src)])

env.Command(auxlib_dst, auxlib_src, [Copy(auxlib_dst, auxlib_src)])

# TODO: Fix this build script to gracefully install auxlib and the man page

#env.Alias(target="install", source=env.Install(dir="/usr/local/bin/", source=("bin/fceux", "bin/auxlib.lua")))

env.Alias(target="install", source=env.Install(dir="/usr/local/bin/", source="bin/fceux"))


 其中使用 -DHAVE_ASPRINTF 主要为解决如下问题

src/file.cpp: In function 'int asprintf(char**, const char*, ...)':

src/file.cpp:464: error: 'int asprintf(char**, const char*, ...)' was declared 'extern'

and later 'static'

/usr/local/arm/4.4.1/bin/../arm-none-linux-gnueabi/libc/usr/include/stdio.h:382:

error: previous declaration of 'int asprintf(char**, const char*, ...)'

注释掉zlib和SDL库的检测主要不知道如何让scons找到嵌入式的库,FC,没办法直接注释掉

否则总会提示

 

scons: Reading SConscript files ...

platform: posix

Checking for inflate in C library z... no

AssertionError: please install: zlib:

File "/home/huisen/workspace/apps/fceu2.1.5/SConstruct", line 58:

assert conf.CheckLibWithHeader('z', 'zlib.h', 'C', 'inflate;', 1), "please install:

zlib"


注释掉env.ParseConfig('sdl-config --cflags --libs') 是防止其引用桌面版的版本。


 修改完毕后,运行./arm-linux.sh 即可成功编译出arm-linux版本的 fceux来.


四 fceux ARM版的运行


在fceux 运行后,会使用 ~/.fceux/fceux.cfg作为配置文件


ARM需要写一个脚本。在最开始的音频运行卡死。因此我成功的运行参数是

  

./fceux --bpp 16 --sound 1 --fullscreen 1 CONTRA.NES


  这里运行效果实拍

  

猜你感兴趣