【发布时间】:2019-05-16 01:00:03
【问题描述】:
我正在开发一个 Space Invaders 模拟器,我正在使用 SDL2 进行显示输出。
问题是在输出窗口上我看到了自模拟开始以来的所有帧!
基本上重要的一段代码是这样的:
Intel8080 mainObject; // My Intel 8080 CPU emulator
mainObject.loadROM();
//Main loop flag
bool quit = false;
//Event handler
SDL_Event e;
//While application is running
while (!quit)
{
//Handle events on queue
while (SDL_PollEvent(&e) != 0)
{
//User requests quit
if (e.type == SDL_QUIT)
{
quit = true;
}
}
if (mainObject.frameReady)
{
mainObject.frameReady = false;
gHelloWorld = SDL_CreateRGBSurfaceFrom(&mainObject.frameBuffer32, 256, 224, 32, 4 * 256, 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff);
//Apply the image
SDL_BlitSurface(gHelloWorld, NULL, gScreenSurface, NULL);
//Update the surface
SDL_UpdateWindowSurface(gWindow);
}
mainObject.executeROM();
}
其中 Intel8080 是我的 CPU 仿真器代码,mainObject.frameBuffer32 是 Space Invaders 的视频 RAM,我将其从 1bpp 转换为 32bpp 以使用 SDL_CreateRGBSurfaceFrom 函数。
仿真运行良好,但我看到自仿真器启动后生成的所有帧!
我尝试更改每个 RGBA 像素的 4 个字节中的 Alpha 值,但没有任何变化
【问题讨论】:
标签: c++ emulation sdl-2 framebuffer