diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml index 272c9a3..8e23c76 100644 --- a/.github/workflows/make.yml +++ b/.github/workflows/make.yml @@ -22,7 +22,7 @@ jobs: - name: Installing apt packages run: sudo apt install libgtest-dev gcovr libtbb-dev libsdl2-dev libsdl2-image-dev - name: Run meson configuration - run: meson setup build -DonlyOpenSource=true + run: meson setup build -DonlyOpenSource=true -DenableArkanoidInputs=true - name: Building project run: ninja -C build - name: Running tests diff --git a/meson_options.txt b/meson_options.txt index fe802da..a519dca 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -26,3 +26,9 @@ option('onlyOpenSource', yield: true ) +option('enableArkanoidInputs', + type : 'boolean', + value : false, + description : 'Build tests', + yield: true +) \ No newline at end of file diff --git a/source/quickerNES/core/core.hpp b/source/quickerNES/core/core.hpp index 810b01f..dcf8426 100644 --- a/source/quickerNES/core/core.hpp +++ b/source/quickerNES/core/core.hpp @@ -719,6 +719,7 @@ class Core : private Cpu void setControllerType(controllerType_t type) { _controllerType = type; } +#ifdef _QUICKERNES_SUPPORT_ARKANOID_INPUTS int read_io(nes_addr_t addr) { if ((addr & 0xFFFE) == 0x4016) @@ -761,10 +762,10 @@ class Core : private Cpu // latch 0 encodes fire uint8_t result = (input_state.arkanoid_fire & 1) * 2; - // latch 0 also encodes joypad 1 + // latch 0 also encodes input_state 1 result += (input_state.joypad_latches[0] & 1) & 1; - // Advancing joypad latch + // Advancing input_state latch input_state.joypad_latches[0] >>= 1; return result; @@ -792,6 +793,26 @@ class Core : private Cpu return addr >> 8; // simulate open bus } +#else + int read_io(nes_addr_t addr) + { + if ((addr & 0xFFFE) == 0x4016) + { + // to do: to aid with recording, doesn't emulate transparent latch, + // so a game that held strobe at 1 and read $4016 or $4017 would not get + // the current A status as occurs on a NES + if (input_state.w4016 & 1) return 0; + const uint8_t result = input_state.joypad_latches[addr & 1] & 1; + input_state.joypad_latches[addr & 1] >>= 1; + return result; + } + + if (addr == Apu::status_addr) + return impl->apu.read_status(clock()); + + return addr >> 8; // simulate open bus + } +#endif void write_io(nes_addr_t addr, int data) { diff --git a/source/quickerNES/meson.build b/source/quickerNES/meson.build index 651718e..6136d30 100644 --- a/source/quickerNES/meson.build +++ b/source/quickerNES/meson.build @@ -28,10 +28,17 @@ quickerNESSrc = quickerNESAPUSrc + quickerNESPPUSrc + [ 'core/cpu.cpp' ] +quickerNESCompileArgs = [ ] + +# Checking for arkanoid input support +if get_option('enableArkanoidInputs') == true + quickerNESCompileArgs += '-D_QUICKERNES_SUPPORT_ARKANOID_INPUTS' +endif + # quickerNES Core Configuration quickerNESDependency = declare_dependency( - compile_args : [ ], + compile_args : quickerNESCompileArgs, include_directories : include_directories(['.', '..']), sources : [ quickerNESSrc ], dependencies : [ diff --git a/tests/meson.build b/tests/meson.build index 5b22461..748ffe5 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -92,6 +92,8 @@ if get_option('onlyOpenSource') == false args : [ testFile, '--cycleType', 'Full'], suite : [ testSuite ]) + if get_option('enableArkanoidInputs') == true + testFile = 'arkanoid.arkNESController.test' testSuite = testFile.split('.')[0] testName = testFile.split('.')[1] @@ -111,4 +113,6 @@ if get_option('onlyOpenSource') == false timeout: testTimeout, args : [ testFile, '--cycleType', 'Full'], suite : [ testSuite ]) + + endif endif \ No newline at end of file