Giter Club home page Giter Club logo

chipz's Introduction

ChipZ

This is a simple Chip8 emulator built using the Zig programming language.

This software was mostly meant to be for me to learn the basics of Zig, but it should be working for general Chip8 emulation.

This emulator was built following This guide for the Chip 8 emulation itself, and This other guide for the SDL2 setup.

Some demo files are in this repository. Here are the sources and description. All credits to the original creators.

  • test_opcode.ch8 is a a general test for Chip 8 emulators

  • bc_test.ch8 is another general test file for Chip 8 emulators

  • IBM Logo.ch8 was found at this link (many interesting roms here!) and is just a display test

  • c8_test.c8 is an excellent testing rom too, with tests on timers.

Building and running

Using the library

src/lib/chipz.zig is a file containing everything needed to start chip 8 emulation. You just need to bring the GUI part to it. For your own use, add this file as a package to your build.zig file.

For an example of how to use the library, check out main.zig or this simple example:

var general_purpose_allocator = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = general_purpose_allocator.allocator();

var emu = chipz.ChipZ.init(gpa);
emu.load_program(buffer);

while (true): {
    if (emu.cycle()) {} else |_| {
        @panic("Faulting instruction");
    }
    if (emu.flags.display_update) {
        // refresh display according to the content of emu.display
    }
}

Building the main program

The ChipZ emulator relies on SDL2. You need to have the SDL2 library available in your system library path to build and run it.

It has been tested on windows and macOS(arm) successfully so far, but should work with linux too.

Running the tests

There are a few tests. zig build test will run them.

Using the emulator

To use the emulator, run "chipz.exe" and pass the rom path as a parameter (i.e chipz.exe my_path/to/my/rom.ch8).

The Chip 8 "COSMAC VIP" keyboard is mapped like this:

Table 1. keys

1

2

3

4

Q

W

E

R

A

S

D

F

Z

X

C

V

Keyboard scancodes are used so any non-qwerty keyboard should have the same mapping.

Sound isn’t managed and won’t be implemented.

Pressing the UP or DOWN key allows to resize the window.

chipz's People

Contributors

arwalk avatar lbureau-billettiqueservices avatar dgv avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.