commit 09acb8875a533c1b877e9650da176da39e47d965 Author: Jairinho Date: Wed Feb 23 12:20:57 2022 -0300 project basic setup diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..30da04e --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,39 @@ +on: [push, pull_request] +name: Test +jobs: + test: + strategy: + matrix: + go-version: [1.16.x, 1.17.x] + os: [ubuntu-latest, macos-latest, windows-latest] + + runs-on: ${{ matrix.os }} + + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Cache control + uses: actions/cache@v2 + with: + # In order: + # * Module download cache + # * Build cache (Linux) + # * Build cache (Mac) + # * Build cache (Windows) + path: | + ~/go/pkg/mod + ~/.cache/go-build + ~/Library/Caches/go-build + %LocalAppData%\go-build + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Test + run: go test -v -race ./chip8 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ca77fe1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,222 @@ + +# Created by https://www.toptal.com/developers/gitignore/api/osx,windows,linux,vim,visualstudiocode,go,goland +# Edit at https://www.toptal.com/developers/gitignore?templates=osx,windows,linux,vim,visualstudiocode,go,goland + +### Go ### +# If you prefer the allow list template instead of the deny list, see community template: +# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore +# +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +# vendor/ + +# Go workspace file +go.work + +### Go Patch ### +/vendor/ +/Godeps/ + +### Goland ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm, Rider and Goland +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Ignores the whole .idea folder and all .iml files +.idea/ + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### OSX ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Vim ### +# Swap +[._]*.s[a-v][a-z] +!*.svg # comment out if you don't need vector files +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide + +# Support for Project snippet scope + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.toptal.com/developers/gitignore/api/osx,windows,linux,vim,visualstudiocode,go,goland \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..a0162b7 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "libretro/libretro-common"] + path = libretro/libretro-common + url = https://github.com/libretro/libretro-common.git diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f6f549c --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ +TARGET=chip8_libretro +LIBRETRO_CORE=$(TARGET).so +LIBRETRO_HEADER=$(TARGET).h + +# run: $(LIBRETRO_CORE) +# retroarch -v -L $(LIBRETRO_CORE) roms/test_opcode.ch8 + +$(LIBRETRO_CORE): + go build -buildmode=c-shared -o $@ ./libretro + +test: + go test -v -race ./chip8 + +clean: + rm $(LIBRETRO_CORE) $(LIBRETRO_HEADER) + diff --git a/README.md b/README.md new file mode 100644 index 0000000..daf95af --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# Chip8 Emulator \ No newline at end of file diff --git a/chip8/chip8.go b/chip8/chip8.go new file mode 100644 index 0000000..2144af5 --- /dev/null +++ b/chip8/chip8.go @@ -0,0 +1 @@ +package chip8 diff --git a/chip8/chip8_test.go b/chip8/chip8_test.go new file mode 100644 index 0000000..3a3f634 --- /dev/null +++ b/chip8/chip8_test.go @@ -0,0 +1 @@ +package chip8_test diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..84a78b7 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/tangzero/chip8-emulator + +go 1.17 diff --git a/libretro/libretro-common b/libretro/libretro-common new file mode 160000 index 0000000..716bb5e --- /dev/null +++ b/libretro/libretro-common @@ -0,0 +1 @@ +Subproject commit 716bb5e7b761a3b4d44e069c84491d906d32aba0 diff --git a/libretro/libretro.go b/libretro/libretro.go new file mode 100644 index 0000000..bf75183 --- /dev/null +++ b/libretro/libretro.go @@ -0,0 +1,32 @@ +package main + +/* +#cgo CFLAGS: -I./libretro-common/include +#include "libretro.h" + +typedef struct retro_system_info retro_system_info; +typedef struct retro_system_av_info retro_system_av_info; +*/ +import "C" +import ( + "fmt" +) + +const RetroAPIVersion = 1 + +//export retro_init +func retro_init() { + fmt.Println("loading chip8 core...") +} + +//export retro_deinit +func retro_deinit() { + fmt.Println("unloading chip8 core...") +} + +//export retro_api_version +func retro_api_version() uint32 { + return RetroAPIVersion +} + +func main() {} diff --git a/roms/test_opcode.ch8 b/roms/test_opcode.ch8 new file mode 100644 index 0000000..f540f69 Binary files /dev/null and b/roms/test_opcode.ch8 differ