Giter VIP home page Giter VIP logo

jaktnesmonster's Introduction

Jakt NES Monster

Creating a NES emulator in the jakt programming language.

Videos

JT has documented a lot of their work on Jakt NES Monster in a playlist on their YouTube channel, Systems with JT.

Building

Make sure you have libsdl2+SDL2 headers installed, and build and install the jakt compiler into your PATH.

Building using jakt directly

With jakt in your path and the install location of SDL2 known, you can build like so for Linux:

> jakt src/main.jakt -l SDL2 -I <path to Jakt runtime directory> -O -o jakt_nes

On macOS, you can use (be sure to update versions to match your SDL2 version):

> jakt src/main.jakt -l SDL2 -I /opt/homebrew/Cellar/sdl2/2.0.22/include -L /opt/homebrew/Cellar/sdl2/2.0.22/lib -I ../jakt/runtime -O -o jakt_nes

For Windows, keep reading into the CMake steps :^).

Building using CMake

Instead of installing jakt into somewhere that's in your path, make sure to install jakt via the CMake build by setting CMAKE_INSTALL_PREFIX somewhere interesting, or passing --prefix on the command line . One decent option for prefix is "jakt-install".

jakt> cmake -B build -GNinja -DCMAKE_INSTALL_PREFIX=jakt-install -DCMAKE_CXX_COMPILER=clang++
jakt> cmake --build build
jakt> cmake --install build
# alternative to setting CMAKE_INSTALL_PREFIX
jakt> cmake --install build --prefix jakt-test

After that, you can build jaktnesmonster by passing the location of jakt CMake files to CMake. CMake should find SDL2 automatically, if it's in a standard install location for your platform (Linux, macOS, other Unix).

> cmake -G Ninja -B build -DCMAKE_PREFIX_PATH=../jakt/jakt-install -DCMAKE_CXX_COMPILER=clang++
> cmake --build build
# Alternatively
> ninja -C build

Building on Windows

The easiest way to hook up SDL2 to CMake on windows is via vcpkg

Ensure that you have the VS 2019 or 2022 toolset installed, including clang. MSVC is not supported.

Perform the above jakt install steps from a VS Developer Powershell instance.

Next, install SDL2 via vcpkg from a VS Developer PowerShell instance:

git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
.\bootstrap-vcpkg.bat
.\vcpkg install sdl2:x64-windows

Finally, configure jaktnesmonster with CMake, passing your Windows install of jakt, the vcpkg toolchain file, and clang++ as the C++ compiler:

cmake -B build -GNinja `
    -DCMAKE_PREFIX_PATH="..\jakt\jakt-install\share" `
    -DCMAKE_TOOLCHAIN_FILE="..\vcpkg\scripts\buildsystems\vcpkg.cmake" `
    -DCMAKE_CXX_COMPILER=clang++

Now you can build jakt_nes.exe via

> cmake --build build

or

> ninja -C build

Alternatively, using Visual Studio directly to build, you can create a CMakeSettings.json similar to:

{
  "configurations": [
    {
      "name": "x64-Debug",
      "generator": "Ninja",
      "configurationType": "Debug",
      "inheritEnvironments": [ "clang_cl_x64_x64" ],
      "buildRoot": "${projectDir}\\out\\build\\${name}",
      "installRoot": "${projectDir}\\out\\install\\${name}",
      "cmakeCommandArgs": "-DCMAKE_PREFIX_PATH=\"..\\jakt\\jakt-install\\share\" ",
      "buildCommandArgs": "",
      "ctestCommandArgs": "",
      "cmakeToolchain": "..\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake"
    }
  ]
}

jaktnesmonster's People

Contributors

sophiajt avatar optimoos avatar holladiewal avatar adkaster avatar pedro-ximenez avatar haakonnessjoen avatar maclarsson avatar

Stargazers

 avatar Andrejs Agejevs avatar Jose Mendoza  avatar  avatar Lord Norlan Mumar avatar Humberto Alves avatar Name avatar  avatar hellisabove avatar Brett Moore avatar Daniel Tanev avatar  avatar  avatar Andrei Bocan avatar Alex Bouma avatar astrolemonade avatar Andrew Chou avatar SimVV.exe avatar Marcelle Rusu avatar Aleksey avatar Sarah avatar Daniel Oberhoff avatar Simon Richardson avatar Ruairidh MacLeod avatar Caleb avatar Isabelle avatar Dan Minshew avatar Pascal Puffke avatar Matthias Thym avatar ddg() avatar Steve Francia avatar Julia avatar Micah avatar  avatar Paul Redmond avatar David Pendray avatar  avatar Paul Wratt avatar Brandon Jordan avatar Lesley Lai avatar  avatar Dmytro Sirenko avatar Micke Nordin avatar Kauê 地球の土星人 avatar Suraj avatar Maarten Steevens avatar Dom Newman avatar Paulo G.J. Bezerra avatar yeppiidev avatar Martin Lindhe avatar Andrea Cisternino avatar Hjalmar Andersen avatar Tomás Malbrán avatar coderock avatar Amit avatar David Capello avatar Kesse Jones avatar Redion Xhepa avatar Jakub Žádník avatar Mehmet Berkay Yüksel avatar Vincent Rischmann avatar Brad Svercl avatar Bruno avatar  avatar Tsvetomir Bonev avatar Stuart Axon avatar  avatar  avatar DerpyCrabs avatar Itai Nelken avatar Kenneth Myhra avatar Victor Shilin avatar Kristiyan Stoimenov avatar Surrealegg avatar Andreas Kling avatar Kyle Lanmon avatar Travis B. Hartwell avatar

Watchers

 avatar Kenneth Söderlund avatar Paul Wratt avatar  avatar

jaktnesmonster's Issues

Emulator does not run outside of release mode

cmake -G Ninja -B build -DCMAKE_PREFIX_PATH=../jakt/jakt-install -DCMAKE_CXX_COMPILER=clang++-15 -DCMAKE_BUILD_TYPE=Release

👍

cmake -G Ninja -B build -DCMAKE_PREFIX_PATH=../jakt/jakt-install -DCMAKE_CXX_COMPILER=clang++-15 -DCMAKE_BUILD_TYPE=Debug

👎

example run:

./build/jakt_nes ~/Downloads/Super\ Mario\ Bros\ \(E\).nes 
prg_rom: 2
chr_rom: 1
mirroring: Mirroring::Vertical
mapper: 0
Debugging keys
--------------
D - hold to dump current CPU info
H - toggle CPU halt
J - When halted, run single frame
L - toggle slow mode
Panic: Overflow in checked addition '65532 + 8'
jakt_nes: /home/andrew/jakt/jakt-install/include/runtime/lib.h:84: void JaktInternal::panic(AK::StringView): Assertion `false' failed.
Aborted (core dumped)

This is running into the TODO in Pulse here:

https://github.com/jntrnr/jaktnesmonster/blob/998eea4c4ec0414c98d0ba86b4ae7a4f40f2a0cd/src/apu.jakt#L105-L108

Note that in Release, integer overflow is not Checked, but in Debug or "not release" mode it is checked, and crashes quickly by overflowing the 16 bit counter, adding 8 to it each 'tick'.

Add link to videos in readme..

I love to see the code, but the most important thing is the videos, so it would be interesting if you refer to them here. 😉

nestest failing due to PPU $2007 behavior

It's too late for me to code the solution for this so I thought I'd at least note my investigations in an issue. nestest is crashing because of the "else" in ppu_data_write

https://github.com/jntrnr/jaktnesmonster/blob/9307f5e49b0da684b518cb1de13174b4af7790b3/src/ppu.jakt#L477

The correct behavior is described here - https://www.nesdev.org/wiki/PPU_scrolling#$2007_reads_and_writes

The pre-render scanline (to support the above correct behavior) is described here - https://www.nesdev.org/wiki/PPU_rendering#Pre-render_scanline_(-1_or_261)

Sprite priorities

Right now we go through sprites 0 to 63 and figure out which sprites will be visible in the scanline. That works well, but for some games (like dragon warrior 1) we're drawing later sprites over top of earlier sprites. We'll need to support sprite priorities so we don't overwrite the higher priority sprites

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.