ARTICLE DETAIL

资讯详情

深耕网站建设、视觉设计与SEO优化的一线实战洞察。

0329-Chip8-俄罗斯方块

0329-Chip8-俄罗斯方块

环境

  • Time 2023-07-27
  • Zig 0.11.0-dev.4191+1bf16b172
  • SLD2 2.28.1

前言

说明

参考资料:

  1. https://en.wikipedia.org/wiki/CHIP-8
  2. https://austinmorlan.com/posts/chip8_emulator/
  3. https://rsj217.github.io/chip8-py/
  4. https://github.com/Timendus/chip8-test-suite

其中最后一个提供了测试的套件,实现的过程中,可以检测哪些指令有问题,帮助很大。

目标

通过自己实现的 Chip8 模拟器,来加载俄罗斯方块游戏。

main.zig

const std = @import("std");
const chip8 = @import("chip8.zig");pub fn main() !void {// const rom = @embedFile("roms/1-chip8-logo.ch8");// const rom = @embedFile("roms/2-ibm-logo.ch8");// const rom = @embedFile("roms/3-corax+.ch8");// const rom = @embedFile("roms/4-flags.ch8");// const rom = @embedFile("roms/5-quirks.ch8");// const rom = @embedFile("roms/6-keypad.ch8");const rom = @embedFile("roms/tetris.rom");var emulator = chip8.Emulator.new(rom);emulator.run();
}

启动

zig build run

效果

窗口

总结

通过自己实现的 Chip8 模拟器,来加载俄罗斯方块游戏。最终完成的代码:https://github.com/jiangbo/game/tree/main/zig/chip8

附录

返回列表