1 Star 0 Fork 0

杨伯均/ines

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.c 1002 Bytes
一键复制 编辑 原始数据 按行查看 历史
杨伯均 提交于 2024-01-04 21:55 +08:00 . :boom:初步实现ppu输出
#include "util.h"
#include <errno.h>
#include <string.h>
static uint8 pixels[PPU_VIDEO_HEIGHT * PPU_VIDEO_WIDTH * 3];
static void ines_game_callback(const uint8 *pixelBuf) {
for (int i = 0; i < PPU_VIDEO_HEIGHT; ++i) {
uint32 offset = i * PPU_VIDEO_WIDTH;
for (int j = 0; j < PPU_VIDEO_WIDTH; ++j) {
uint32 k = (offset + j) * 3;
uint8 idx = pixelBuf[k] & 0x3F;
const uint8 *pixel = DEF_PPU_PALETTE[idx];
pixels[k] = pixel[0];
pixels[k + 1] = pixel[1];
pixels[k + 2] = pixel[3];
}
}
}
int main() {
uint8 *buffer = ines_fread_all("../rom/ines.nes", NULL);
NesConsole *console = ines_console_new(buffer, ines_game_callback);
if (console == NULL) {
String str = ines_error_text(errno);
printf("Console instance fail:%s\n", str);
return -1;
}
while (True) {
ines_console_execute(console);
}
ines_console_dispose(&console);
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/navigatorCode/ines.git
git@gitee.com:navigatorCode/ines.git
navigatorCode
ines
ines
master

搜索帮助