很多小伙伴玩家都不太清楚dc模拟器|C#搭建跨平台桌面NES游戏模拟器,那么今天解雕侠小编给大家带来一篇 相关的文章,希望大家看了之后能有所收获,最后请大家持续关注我们!
支持,Mac,Linux NES模拟器内核源码来自他的源码。 功能很齐全,支持录像,摇杆dc模拟器,金手指等等。
现在移植到cpf实现跨平台测试,但是这里的移植测试还没有完全移植所有的功能。

移植这个主要是图形渲染和音频播放适配。
需要开启代码优化才能有足够的帧数,不然会很卡。
绘图和控制的代码主要在类中

绘制游戏画面
protected override void OnRender(DrawingContext dc)
{
base.OnRender(dc);
if (bitmapBuffer != null)
{
dc.DrawImage(bitmapBuffer.Bitmap, new Rect(new Point(), ActualSize), new Rect(0, 0, bitmapBuffer.Bitmap.Width, bitmapBuffer.Bitmap.Height));
if (gameState == GameState.Paused)
{
var size = ActualSize;
dc.DrawImage(FilterPause, new Rect(new Point(), ActualSize), new Rect(0, 0, FilterPause.Width, FilterPause.Height));
var textSize = dc.DrawingFactory.MeasureString("暂停", new Font(FontFamily, 36, FontStyles.Italic));
var outlineThickness = size.Height / 120;
textSize.Width += outlineThickness;
textSize.Height += outlineThickness;
float textX = (size.Width - textSize.Width) / 2;
float textY = (size.Height - textSize.Height) / 2;
using (PathGeometry graphicsPath = new PathGeometry(new Font(this.FontFamily, 36, FontStyles.Italic), "暂停"))
using (SolidColorBrush outlinePen = new SolidColorBrush(Color.Black))
using (LinearGradientBrush linearGradientBrush = new LinearGradientBrush(new GradientStop[] { new GradientStop(Color.White, 0), new GradientStop(Color.LightSkyBlue, 1) }, new Point(), new Point(0, textSize.Height), Matrix.Identity))
{
var m = Matrix.Identity;
m.Translate(textX, textY);
graphicsPath.Transform(m);
dc.DrawPath(outlinePen, new Stroke(outlineThickness) { LineJoin = LineJoins.Round }, graphicsPath);
dc.FillPath(linearGradientBrush, graphicsPath);
}
}
}
}
键盘操作
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
if (e.Key == Keys.Tab)
{
e.Handled = true;
}
keyboardState[e.Key] = true;
}
protected override void OnKeyUp(KeyEventArgs e)
{
base.OnKeyUp(e);
keyboardState[e.Key] = false;
}

声音播放采用SDL2,支持跨平台声音播放,在类中实现
源码中带有sdl2的64位dll发布到其他平台需要相应平台安装SDL2。
默认支持直接打开zip文件读取nesdc模拟器,但Net4版本无法读取zip
有兴趣的可以下载研究,需要的。 如果需要cpf设计器,请看cpf入门教程:
源码下载:
上面就是dc模拟器|C#搭建跨平台桌面NES游戏模拟器的全部内容了,希望能给广大手游玩家玩家们带来一些帮助,更多关于的内容,尽在解雕侠!












