一、模仿器源码
源码:https://files.cnblogs.com/files/twzy/arm-NES-linux-master.zip
二、文件体系
文件体系:debian bullseye
利用builtroot2018构建的文件体系,利用InfoNES模仿器存在bug,搞不定,以是放弃,改用debian。
三、编译
在debian文件体系下编译,在f1c200s开发板实验
解压源码进入Linux目录,不用做修改实验make编译。
编译后在f1c200s开发板实验,屏幕可见画面。
启动debian模仿器
mount_debian.sh
- #/bin/bash
- cd rootfs
- sudo mount --bind /dev dev/
- sudo mount --bind /sys sys/
- sudo mount --bind /proc proc/
- sudo mount --bind /dev/pts dev/pts/
- sudo cp /usr/bin/qemu-arm-static usr/bin/
- cd ..
- sudo LC_ALL=C LANGUAGE=C LANG=C chroot rootfs
复制代码 编译:
- cd /home/arm-NES-linux/linux && make
复制代码 退出debian模仿器
unmount_debian.sh
- sudo rm rootfs/usr/bin/qemu-arm-static #删除之前拷贝的文件
- cd rootfs
- sudo umount dev/pts/ # 一定要在/dev前面umount
- sudo umount dev/
- sudo umount sys/
- sudo umount proc/
复制代码 四、适配遥控
builtroot制作的文件体系下调试驱动。
在debian体系下利用:evtest下令
这里利用无线手柄:
在下令行实验:evtest,利用无线手柄可发现有按键变乱上报。
修改NES模仿器源码linux目录下的joypad_input.cpp,使其适配自己的无线手柄。
修改一
- int InitJoypadInput(void)
- {
- int iErr = 0;
- //iErr = RegisterJoypadInput(&joypadInput);
- iErr = RegisterJoypadInput(&usbJoypadInput); // 只注册这个输入
- return iErr;
- }
复制代码 修改二
修改三
- static void *InputEventTreadFunction(void *pVoid)
- {
- /* 定义函数指针 */
- int (*GetJoypad)(void);
- GetJoypad = (int (*)(void))pVoid;
- while (1)
- {
- //因为有阻塞所以没有输入时是休眠
- //g_InputEvent = GetJoypad();
- int data = GetJoypad();
- if (data == -1)
- {
- continue;
- }
- else
- {
- g_InputEvent = data;
- }
- //有数据时唤醒
- pthread_mutex_lock(&g_tMutex);
- //因为有阻塞所以没有输入时是休眠
- pthread_cond_signal(&g_tConVar);
- pthread_mutex_unlock(&g_tMutex);
- }
- }
复制代码 五、测试游戏是否可以正常玩耍
可以无声音畅玩了。
六、先解决debian体系下的语音播放
查抄声卡
默认声卡配置
vi /etc/asound.conf
- defaults.ctl.card 0
- defaults.pcm.card 0
- defaults.timer.card 0
复制代码- amixer controls 用于查看音频系统提供的操作接口
- amixer contents 用于查看接口配置参数
- amixer cget + 接口函数
- amixer cset + 接口函数 + 设置值
- amixer cget numid=14,iface=MIXER,name='ADC Mixer Mic Capture Switch'
- amixer cset numid=14,iface=MIXER,name='ADC Mixer Mic Capture Switch' on
- 打开之后才可以录音
- arecord out.wav
复制代码- root@wang-virtual-machine:~# arecord out.wav
- Recording WAVE 'out.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono
- ^CAborted by signal Interrupt...
- root@wang-virtual-machine:~#
- root@wang-virtual-machine:~#
- root@wang-virtual-machine:~# aplay out.wav
- Playing WAVE 'out.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono
- ^CAborted by signal Interrupt...
复制代码 七、解决NES模仿器的声音
启动游戏会出现七零八落的声音,也不知道对不对。在NES中是通过一些PCM的API利用音频的,具体的看代码吧。
八、mplayer播放音频
mplayer -ao alsa out.wav 特别慢有声音
mplayer -ao alsa test.wav
mplayer -ao alsa test.mp3
- root@wang-virtual-machine:/home# mplayer -ao alsa test.mp3
- MPlayer 1.4 (Debian), built with gcc-10 (C) 2000-2019 MPlayer Team
- do_connect: could not connect to socket
- connect: No such file or directory
- Failed to open LIRC support. You will not be able to use your remote control.
- Playing test.mp3.
- libavformat version 58.45.100 (external)
- Audio only file format detected.
- Load subtitles in ./
- ==========================================================================
- Opening audio decoder: [mpg123] MPEG 1.0/2.0/2.5 layers I, II, III
- AUDIO: 16000 Hz, 2 ch, s16le, 16.0 kbit/3.12% (ratio: 2000->64000)
- Selected audio codec: [mpg123] afm: mpg123 (MPEG 1.0/2.0/2.5 layers I, II, III)
- ==========================================================================
- AO: [alsa] 16000Hz 2ch s16le (2 bytes per sample)
- Video: no video
- Starting playback...
- A: 3.1 (03.0) of 3.0 (03.0) 12.7%
- Exiting... (End of file)
复制代码 有办法去掉connect to socket吗?
是遥控器,通过配置去掉。
- vi /etc/mplayer/mplayer.conf
- lirc=no
复制代码 但依然还是很慢。能正常利用。
九、参考
https://zhuanlan.zhihu.com/p/670785159
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |