Skip to content

Commit

Permalink
Merge pull request #1 from jwt2706/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
jwt2706 authored Apr 28, 2024
2 parents 61e0362 + 937b280 commit 8346e90
Show file tree
Hide file tree
Showing 8 changed files with 718 additions and 8 deletions.
12 changes: 8 additions & 4 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
cc_library(
name = "chip8",
srcs = ["chip8.c"],
hdrs = ["chip8.h"],
srcs = glob(["src/*.c"]),
hdrs = glob(["include/*.h"]),
includes = ["include"],
)

cc_binary(
name = "main",
srcs = ["main.c"],
deps = [":chip8"],
srcs = ["src/main.c"],
deps = [
":chip8",
"@SDL2//:SDL2",
],
)
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# CHIP-8 Emulator
# CHIP-8 <s>Emulator</s> Interpreter
16 changes: 16 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "SDL2",
urls = ["https://www.libsdl.org/release/SDL2-2.0.14.tar.gz"],
sha256 = "d8215b571a581be1332d2106f8036fcb03d12a70bae01e20f424976d275432bc",
build_file_content = """
cc_library(
name = "SDL2",
srcs = glob(["SDL2-2.0.14/src/*.c", "SDL2-2.0.14/include/*.h"]),
hdrs = glob(["SDL2-2.0.14/include/*.h"]),
includes = ["SDL2-2.0.14/include"],
visibility = ["//visibility:public"],
)
"""
)
3 changes: 0 additions & 3 deletions chip8.c

This file was deleted.

File renamed without changes.
19 changes: 19 additions & 0 deletions src/chip8.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "chip8.h"

// CHIP-8 system variables
// (NOTE: chars are 8-bits, shorts are 16-bits)
struct chip8 {
unsigned short opcode; // current operation code
unsigned char memory[4096]; // the CHIP-8 system has 4KB of memory
unsigned char V[16]; // 16 general purpose 8-bit registers
unsigned short I; // memory address
unsigned short pc; // program counter
unsigned char gfx[64 * 32]; // for the monochrome display (size of 64 * 32 pixels)
unsigned char delay_timer; // self explanatory
unsigned char sound_timer; // also self explanatory
unsigned short stack[16]; // stack with 16 levels
unsigned short sp; // stack pointer
unsigned char key[16]; // keypad
};

struct chip8 chip8;
File renamed without changes.

0 comments on commit 8346e90

Please sign in to comment.