summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Guegan <loic.guegan@mailbox.org>2023-12-26 17:51:39 +0100
committerLoic Guegan <loic.guegan@mailbox.org>2023-12-26 17:51:39 +0100
commit5eadac72916ce9d53ffdc3f908a6e414858fe7e0 (patch)
tree4c94efaa376280b44c510bad96eee41c43fc6c3a
parent24aadae14da23e852285d4d726148d260edc147d (diff)
Cleaning repository
-rw-r--r--docs/Makefile20
-rw-r--r--docs/conf.py27
-rw-r--r--docs/index.rst20
-rw-r--r--docs/make.bat35
-rw-r--r--res/roms/README.md (renamed from roms/README.md)0
-rw-r--r--res/roms/games/paddles.ch8 (renamed from roms/games/paddles.ch8)bin560 -> 560 bytes
-rw-r--r--res/roms/games/pong_1player.ch8 (renamed from roms/games/pong_1player.ch8)bin246 -> 246 bytes
-rw-r--r--res/roms/tests/chip8-test-suite/1-chip8-logo.ch8 (renamed from roms/chip8-test-suite/1-chip8-logo.ch8)bin260 -> 260 bytes
-rw-r--r--res/roms/tests/chip8-test-suite/2-ibm-logo.ch8 (renamed from roms/chip8-test-suite/2-ibm-logo.ch8)bin132 -> 132 bytes
-rw-r--r--res/roms/tests/chip8-test-suite/3-corax+.ch8 (renamed from roms/chip8-test-suite/3-corax+.ch8)bin697 -> 697 bytes
-rw-r--r--res/roms/tests/chip8-test-suite/4-flags.ch8 (renamed from roms/chip8-test-suite/4-flags.ch8)bin1041 -> 1041 bytes
-rw-r--r--res/roms/tests/chip8-test-suite/5-quirks.ch8 (renamed from roms/chip8-test-suite/5-quirks.ch8)bin3232 -> 3232 bytes
-rw-r--r--res/roms/tests/chip8-test-suite/6-keypad.ch8 (renamed from roms/chip8-test-suite/6-keypad.ch8)bin913 -> 913 bytes
-rw-r--r--res/roms/tests/chip8-test-suite/7-beep.ch8 (renamed from roms/chip8-test-suite/7-beep.ch8)bin110 -> 110 bytes
-rw-r--r--res/roms/tests/chip8-test-suite/8-scrolling.ch8 (renamed from roms/chip8-test-suite/8-scrolling.ch8)bin1330 -> 1330 bytes
-rw-r--r--res/roms/tests/chiptest.ch8 (renamed from roms/chiptest.ch8)bin709 -> 709 bytes
-rw-r--r--res/roms/tests/ibm.ch8 (renamed from roms/ibm.ch8)bin132 -> 132 bytes
-rw-r--r--res/speaker/beep.mp3 (renamed from src/beep2.mp3)bin2295 -> 2295 bytes
-rw-r--r--src/beep.h194
-rw-r--r--src/beep.mp3bin5320 -> 0 bytes
-rw-r--r--src/keypad.c8
-rw-r--r--src/keypad.h5
-rw-r--r--src/main.c19
-rw-r--r--src/mem.h46
-rw-r--r--src/screen.c10
-rw-r--r--src/screen.h40
-rw-r--r--src/speaker.c10
-rw-r--r--src/speaker.h23
-rw-r--r--src/vcpu.c2
-rw-r--r--src/vcpu.h63
30 files changed, 380 insertions, 142 deletions
diff --git a/docs/Makefile b/docs/Makefile
deleted file mode 100644
index d4bb2cb..0000000
--- a/docs/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-# Minimal makefile for Sphinx documentation
-#
-
-# You can set these variables from the command line, and also
-# from the environment for the first two.
-SPHINXOPTS ?=
-SPHINXBUILD ?= sphinx-build
-SOURCEDIR = .
-BUILDDIR = _build
-
-# Put it first so that "make" without argument is like "make help".
-help:
- @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
-
-.PHONY: help Makefile
-
-# Catch-all target: route all unknown targets to Sphinx using the new
-# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
-%: Makefile
- @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
diff --git a/docs/conf.py b/docs/conf.py
deleted file mode 100644
index 738a5e7..0000000
--- a/docs/conf.py
+++ /dev/null
@@ -1,27 +0,0 @@
-# Configuration file for the Sphinx documentation builder.
-#
-# For the full list of built-in configuration values, see the documentation:
-# https://www.sphinx-doc.org/en/master/usage/configuration.html
-
-# -- Project information -----------------------------------------------------
-# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
-
-project = 'Chip-8'
-copyright = '2023, Loïc Guégan'
-author = 'Loïc Guégan'
-
-# -- General configuration ---------------------------------------------------
-# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
-
-extensions = []
-
-templates_path = ['_templates']
-exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
-
-
-
-# -- Options for HTML output -------------------------------------------------
-# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
-
-html_theme = 'sphinx_rtd_theme'
-html_static_path = ['_static']
diff --git a/docs/index.rst b/docs/index.rst
deleted file mode 100644
index 5825200..0000000
--- a/docs/index.rst
+++ /dev/null
@@ -1,20 +0,0 @@
-.. Chip-8 documentation master file, created by
- sphinx-quickstart on Sun Dec 24 17:49:23 2023.
- You can adapt this file completely to your liking, but it should at least
- contain the root `toctree` directive.
-
-Welcome to Chip-8's documentation!
-==================================
-
-.. toctree::
- :maxdepth: 2
- :caption: Contents:
-
-
-
-Indices and tables
-==================
-
-* :ref:`genindex`
-* :ref:`modindex`
-* :ref:`search`
diff --git a/docs/make.bat b/docs/make.bat
deleted file mode 100644
index 32bb245..0000000
--- a/docs/make.bat
+++ /dev/null
@@ -1,35 +0,0 @@
-@ECHO OFF
-
-pushd %~dp0
-
-REM Command file for Sphinx documentation
-
-if "%SPHINXBUILD%" == "" (
- set SPHINXBUILD=sphinx-build
-)
-set SOURCEDIR=.
-set BUILDDIR=_build
-
-%SPHINXBUILD% >NUL 2>NUL
-if errorlevel 9009 (
- echo.
- echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
- echo.installed, then set the SPHINXBUILD environment variable to point
- echo.to the full path of the 'sphinx-build' executable. Alternatively you
- echo.may add the Sphinx directory to PATH.
- echo.
- echo.If you don't have Sphinx installed, grab it from
- echo.https://www.sphinx-doc.org/
- exit /b 1
-)
-
-if "%1" == "" goto help
-
-%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
-goto end
-
-:help
-%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
-
-:end
-popd
diff --git a/roms/README.md b/res/roms/README.md
index e3e6474..e3e6474 100644
--- a/roms/README.md
+++ b/res/roms/README.md
diff --git a/roms/games/paddles.ch8 b/res/roms/games/paddles.ch8
index 26af3d2..26af3d2 100644
--- a/roms/games/paddles.ch8
+++ b/res/roms/games/paddles.ch8
Binary files differ
diff --git a/roms/games/pong_1player.ch8 b/res/roms/games/pong_1player.ch8
index 65d6310..65d6310 100644
--- a/roms/games/pong_1player.ch8
+++ b/res/roms/games/pong_1player.ch8
Binary files differ
diff --git a/roms/chip8-test-suite/1-chip8-logo.ch8 b/res/roms/tests/chip8-test-suite/1-chip8-logo.ch8
index 8f83105..8f83105 100644
--- a/roms/chip8-test-suite/1-chip8-logo.ch8
+++ b/res/roms/tests/chip8-test-suite/1-chip8-logo.ch8
Binary files differ
diff --git a/roms/chip8-test-suite/2-ibm-logo.ch8 b/res/roms/tests/chip8-test-suite/2-ibm-logo.ch8
index d60dac8..d60dac8 100644
--- a/roms/chip8-test-suite/2-ibm-logo.ch8
+++ b/res/roms/tests/chip8-test-suite/2-ibm-logo.ch8
Binary files differ
diff --git a/roms/chip8-test-suite/3-corax+.ch8 b/res/roms/tests/chip8-test-suite/3-corax+.ch8
index 317029b..317029b 100644
--- a/roms/chip8-test-suite/3-corax+.ch8
+++ b/res/roms/tests/chip8-test-suite/3-corax+.ch8
Binary files differ
diff --git a/roms/chip8-test-suite/4-flags.ch8 b/res/roms/tests/chip8-test-suite/4-flags.ch8
index 431f3b0..431f3b0 100644
--- a/roms/chip8-test-suite/4-flags.ch8
+++ b/res/roms/tests/chip8-test-suite/4-flags.ch8
Binary files differ
diff --git a/roms/chip8-test-suite/5-quirks.ch8 b/res/roms/tests/chip8-test-suite/5-quirks.ch8
index 5206652..5206652 100644
--- a/roms/chip8-test-suite/5-quirks.ch8
+++ b/res/roms/tests/chip8-test-suite/5-quirks.ch8
Binary files differ
diff --git a/roms/chip8-test-suite/6-keypad.ch8 b/res/roms/tests/chip8-test-suite/6-keypad.ch8
index 88250bf..88250bf 100644
--- a/roms/chip8-test-suite/6-keypad.ch8
+++ b/res/roms/tests/chip8-test-suite/6-keypad.ch8
Binary files differ
diff --git a/roms/chip8-test-suite/7-beep.ch8 b/res/roms/tests/chip8-test-suite/7-beep.ch8
index 27c205f..27c205f 100644
--- a/roms/chip8-test-suite/7-beep.ch8
+++ b/res/roms/tests/chip8-test-suite/7-beep.ch8
Binary files differ
diff --git a/roms/chip8-test-suite/8-scrolling.ch8 b/res/roms/tests/chip8-test-suite/8-scrolling.ch8
index eb546e7..eb546e7 100644
--- a/roms/chip8-test-suite/8-scrolling.ch8
+++ b/res/roms/tests/chip8-test-suite/8-scrolling.ch8
Binary files differ
diff --git a/roms/chiptest.ch8 b/res/roms/tests/chiptest.ch8
index 4864260..4864260 100644
--- a/roms/chiptest.ch8
+++ b/res/roms/tests/chiptest.ch8
Binary files differ
diff --git a/roms/ibm.ch8 b/res/roms/tests/ibm.ch8
index 113338e..113338e 100644
--- a/roms/ibm.ch8
+++ b/res/roms/tests/ibm.ch8
Binary files differ
diff --git a/src/beep2.mp3 b/res/speaker/beep.mp3
index 74b0956..74b0956 100644
--- a/src/beep2.mp3
+++ b/res/speaker/beep.mp3
Binary files differ
diff --git a/src/beep.h b/src/beep.h
new file mode 100644
index 0000000..3261618
--- /dev/null
+++ b/src/beep.h
@@ -0,0 +1,194 @@
+const unsigned char beep[] = {
+0xff, 0xfb, 0x90, 0xc4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x69, 0x6e,
+0x67, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x08,
+0xf7, 0x00, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71,
+0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71,
+0x71, 0x71, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c,
+0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c,
+0x9c, 0x9c, 0x9c, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1,
+0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1,
+0xf1, 0xf1, 0xf1, 0xf1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x50, 0x4c, 0x41, 0x4d,
+0x45, 0x33, 0x2e, 0x31, 0x30, 0x30, 0x04, 0xb9, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x15, 0x20, 0x24, 0x06, 0x7f, 0x41, 0x00, 0x01,
+0xe0, 0x00, 0x00, 0x08, 0xf7, 0x9f, 0xa0, 0x67, 0x7d, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xfb, 0xd0,
+0xc4, 0x00, 0x00, 0x07, 0x40, 0x03, 0x83, 0xb4, 0x10, 0x00, 0x24, 0x44,
+0xbc, 0xee, 0xff, 0x35, 0xa2,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xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+0xaa, 0xaa, 0xaa,
+};
diff --git a/src/beep.mp3 b/src/beep.mp3
deleted file mode 100644
index 09f4219..0000000
--- a/src/beep.mp3
+++ /dev/null
Binary files differ
diff --git a/src/keypad.c b/src/keypad.c
index 2ff7be4..e0073e9 100644
--- a/src/keypad.c
+++ b/src/keypad.c
@@ -1,5 +1,6 @@
#include "keypad.h"
+/// @brief Define you keymaps here
int map[]={
KEY_X, // 0
KEY_ONE, // 1
@@ -19,6 +20,12 @@ int map[]={
KEY_V // F
};
+/**
+ * @brief Get hex from keycode (used only in this file)
+ *
+ * @param keycode
+ * @return int
+ */
int KeypadGetKey(int keycode){
for(int i=0;i<16;i++){
if(map[i]==keycode)
@@ -27,7 +34,6 @@ int KeypadGetKey(int keycode){
return -1;
}
-
int KeypadGetPressed(){
for(int i=0;i<16;i++){
if(IsKeyDown(map[i]))
diff --git a/src/keypad.h b/src/keypad.h
index 922d2a8..23a6a70 100644
--- a/src/keypad.h
+++ b/src/keypad.h
@@ -2,5 +2,10 @@
#include "raylib.h"
+/**
+ * @brief Return the hex code of the key currently pressed and -1 ortherwise
+ *
+ * @return int
+ */
int KeypadGetPressed();
diff --git a/src/main.c b/src/main.c
index 02e61d0..de3ae0d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -5,17 +5,20 @@
#include <stdio.h>
-//#define ROM "../roms/chip8-test-suite/5-quirks.ch8"
-//#define ROM "../roms/chip8-test-suite/8-scrolling.ch8"
-#define ROM "../roms/games/pong_1player.ch8"
-//#define ROM "../roms/ibm.ch8"
-
int main(int argc, char *argv[])
{
+ // Parse argument
+ if(argc != 2){
+ printf("Usage: %s [rom]\n",argv[0]);
+ return 1;
+ } else if(!FileExists(argv[1])){
+ printf("ROM not found: %s\n",argv[1]);
+ return 1;
+ }
// Initialize
MemInit();
- MemLoadROM(ROM);
+ MemLoadROM(argv[1]);
ScreenInit(1000,500);
VCPUInit();
SpeakerInit();
@@ -24,12 +27,8 @@ int main(int argc, char *argv[])
SetTargetFPS(VCPU_FREQ*100);
// Emulator main loop
- int i=0;
while (!WindowShouldClose()){
VCPUTick();
- if(i%600 == 0)
- printf("tick\n");
- i++;
}
// Finish
diff --git a/src/mem.h b/src/mem.h
index 8e4136a..6ea4e01 100644
--- a/src/mem.h
+++ b/src/mem.h
@@ -3,10 +3,56 @@
#define ADDR_ROM 0x200
#define ADDR_FONT 0x50
+/**
+ * @brief Must be called first!
+ *
+ */
void MemInit();
+
+/**
+ * @brief Set value of a memory region
+ *
+ * @param addr
+ * @param value
+ * @param size
+ */
void MemSet(int addr, unsigned char value, int size);
+
+/**
+ * @brief Store date in memory
+ *
+ * @param data
+ * @param size
+ * @param addr
+ */
void MemStore(unsigned char *data, int size, int addr);
+
+/**
+ * @brief Load data from memory
+ *
+ * @param data
+ * @param size
+ * @param addr
+ */
void MemLoad(unsigned char *data, int size, int addr);
+
+/**
+ * @brief Load ROM into memory (be careful, file MUST exists)
+ *
+ * @param path
+ */
void MemLoadROM(char *path);
+
+/**
+ * @brief Dump the entire memory
+ *
+ */
void MemDump();
+
+/**
+ * @brief Dump a memory region
+ *
+ * @param addr
+ * @param size
+ */
void MemDumpRange(int addr, int size);
diff --git a/src/screen.c b/src/screen.c
index a445bd8..305a40f 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -14,7 +14,7 @@ void ScreenInit(int width, int height){
ScreenClear();
SetTraceLogLevel(LOG_ERROR); // Disable anoying raylib logs
- InitWindow(width, height, "Chip-8 Emulator");
+ InitWindow(width, height, "Chip-8 Emulator by Loïc Guégan");
}
void ScreenClear() {
@@ -26,7 +26,6 @@ void ScreenClear() {
void ScreenUpdate(){
BeginDrawing();
ClearBackground(RAYWHITE);
- // DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
for(int x=0;x<64;x++){
for(int y=0;y<32;y++){
if(Screen.pixels[x+y*64] == 0)
@@ -56,13 +55,6 @@ char ScreenPixelApply(int x, int y, unsigned char state){
return flag;
}
-void ScreenPixelFlip(int x, int y){
- if(Screen.pixels[x+y*64]==0)
- Screen.pixels[x+y*64]=1;
- else
- Screen.pixels[x+y*64]=0;
-}
-
void ScreenWH(int *width, int *height){
*width=64;
*height=32;
diff --git a/src/screen.h b/src/screen.h
index 671285a..075d45a 100644
--- a/src/screen.h
+++ b/src/screen.h
@@ -3,7 +3,7 @@
#include "raylib.h"
#define MODE_CHIP8 0 // Chip-8 64x32
-#define MODE_SCHIP 1 // Super-Chip 128x64
+#define MODE_SCHIP 1 // Super-Chip 128x64 (not supported yet)
typedef struct SCREEN_DATA {
int width, height;
@@ -13,10 +13,46 @@ typedef struct SCREEN_DATA {
char pixels[64*32];
} SCREEN_DATA;
+/**
+ * @brief Must be called first!
+ *
+ * @param width
+ * @param height
+ */
void ScreenInit(int width, int height);
+
+/**
+ * @brief Clear the entire simulated screen
+ *
+ */
void ScreenClear();
+
+/**
+ * @brief Set the pixel's state of the simulated screen (follow the chip-8 specification)
+ *
+ * @param x
+ * @param y
+ * @param state
+ * @return char 1 if pixel was already on and 0 otherwise
+ */
char ScreenPixelApply(int x, int y, unsigned char state);
-void ScreenPixelFlip(int x, int y);
+
+/**
+ * @brief Get simulated screen dimensions
+ *
+ * @param width
+ * @param height
+ */
void ScreenWH(int *width, int *height);
+
+/**
+ * @brief Draw simulated screen instantly
+ *
+ */
void ScreenUpdate();
+
+/**
+ * @brief Close screen (must be called before quit)
+ *
+ */
void ScreenClose();
diff --git a/src/speaker.c b/src/speaker.c
index b4bef73..051902b 100644
--- a/src/speaker.c
+++ b/src/speaker.c
@@ -1,17 +1,19 @@
#include "speaker.h"
+#include "beep.h"
Sound s;
void SpeakerInit(){
- InitAudioDevice(); // Initialize audio device
- s=LoadSound(SPEAKER_AUDIO_FILE);
+ InitAudioDevice(); // Initialize audio device
+ Wave w=LoadWaveFromMemory(".mp3", beep, sizeof(beep));
+ s=LoadSoundFromWave(w);
}
-void SpeakerOn(){
+void SpeakerPlay(){
PlaySound(s);
}
-void SpeakerOff(){
+void SpeakerStop(){
StopSound(s);
}
diff --git a/src/speaker.h b/src/speaker.h
index d78812c..15a3030 100644
--- a/src/speaker.h
+++ b/src/speaker.h
@@ -2,7 +2,26 @@
#define SPEAKER_AUDIO_FILE "beep2.mp3"
+/**
+ * @brief Must be called first
+ *
+ */
void SpeakerInit();
-void SpeakerOn();
-void SpeakerOff();
+
+/**
+ * @brief Play beep one time
+ *
+ */
+void SpeakerPlay();
+
+/**
+ * @brief Stop beep (interrupt it)
+ *
+ */
+void SpeakerStop();
+
+/**
+ * @brief Must be called before exiting the application
+ *
+ */
void SpeakerFinish();
diff --git a/src/vcpu.c b/src/vcpu.c
index 4682f0b..4bfd86b 100644
--- a/src/vcpu.c
+++ b/src/vcpu.c
@@ -322,7 +322,7 @@ void VCPUTick(){
// Play sound
if(State.ST>0)
- SpeakerOn();
+ SpeakerPlay();
// Refresh screen
if(State.screen_ticks>=(1.0*VCPU_FREQ/SCREEN_FREQ)){
diff --git a/src/vcpu.h b/src/vcpu.h
index 16de017..4266ac4 100644
--- a/src/vcpu.h
+++ b/src/vcpu.h
@@ -5,28 +5,31 @@
#define SCREEN_FREQ 60
#define REG_FLAG 0xF
+/**
+ * @brief Store the entire VCPU state
+ *
+ */
typedef struct VCPU_State {
- // Program Counter (16 bits but only 12 bits used (4096 memory addresses))
+ /// @brief Program Counter (16 bits but only 12 bits used (4096 memory addresses))
unsigned short PC;
- // Index register (16 bits but only 12 bits used (4096 memory addresses))
+ /// @brief Index register (16 bits but only 12 bits used (4096 memory addresses))
unsigned short I;
- // Stack register (16 bits)
+ /// @brief Stack register (16 bits)
unsigned short S;
unsigned short stack[100]; // Emulated stack
- // General purpose registers (8 bits each)
- // Note last one often used as a flag register
- unsigned char V[16];
+ /// @brief General purpose registers (8 bits each)
+ unsigned char V[16]; // Note last one often used as a flag register
- // Delay timer (8 bits)
+ /// @brief Delay timer (8 bits)
unsigned char DT;
- // Sound timer (8 bits)
+ /// @brief Sound timer (8 bits)
unsigned char ST;
- // Intruction (opcode + decoded fields)
+ /// @brief Intruction (opcode + decoded fields)
unsigned short opcode;
unsigned char X;
unsigned char Y;
@@ -34,20 +37,58 @@ typedef struct VCPU_State {
unsigned char NN;
unsigned short NNN;
- // Keypressed
+ /// @brief Keypressed
int keypressed; // Not 0 if a key was pressed
unsigned char key;
- // Count VCPU ticks
+ /// @brief Count VCPU ticks
int dt_ticks;
int st_ticks;
int screen_ticks;
} VCPU_State;
+/**
+ * @brief Must be called first!
+ *
+ */
void VCPUInit();
+
+/**
+ * @brief Fetch instruction from memory
+ *
+ */
void VCPUFetch();
+
+/**
+ * @brief Decode instruction from the last fetch
+ *
+ */
void VCPUDecode();
+
+/**
+ * @brief Execute decode instruction
+ *
+ */
void VCPUExecute();
+
+/**
+ * @brief Fetch, decode and execute an instruction
+ *
+ */
void VCPUTick();
+
+/**
+ * @brief Simple (a bit) binary to BCD convertion
+ *
+ * @param x
+ * @param u
+ * @param t
+ * @param h
+ */
void VCPUDoubleDabble(unsigned char x, unsigned char *u, unsigned char *t, unsigned char *h);
+
+/**
+ * @brief Dump VCPU state
+ *
+ */
void VCPUDump();