Skip to content

Add examples #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Apr 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
96 changes: 93 additions & 3 deletions .github/workflows/make.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
- uses: actions/upload-artifact@v4
if: always()
with:
name: meson-logs
name: meson-logs-QuickerNES
path: build/meson-logs/

# Build (QuickerNESArkanoid)
Expand All @@ -90,6 +90,13 @@ jobs:
run: meson setup build -Dbuildtype=release -Db_coverage=true -DuseNCurses=false -Demulator=QuickerNESArkanoid
- name: Building project
run: ninja -C build
- name: Validating examples
run: meson test -C build
- uses: actions/upload-artifact@v4
if: always()
with:
name: meson-logs-QuickerNESArkanoid
path: build/meson-logs/

# Build (QuickerSDLPoP)
build-QuickerSDLPoP:
Expand All @@ -112,6 +119,13 @@ jobs:
run: meson setup build -Dbuildtype=release -DuseNCurses=false -Demulator=QuickerSDLPoP
- name: Building project
run: ninja -C build
- name: Validating examples
run: meson test ValidateExamples -C build
- uses: actions/upload-artifact@v4
if: always()
with:
name: meson-logs-QuickerSDLPoP
path: build/meson-logs/

# Build (QuickerSnes9x)
build-QuickerSnes9x:
Expand All @@ -134,6 +148,13 @@ jobs:
run: meson setup build -Dbuildtype=release -DuseNCurses=false -Demulator=QuickerSnes9x
- name: Building project
run: ninja -C build
- name: Validating examples
run: meson test ValidateExamples -C build
- uses: actions/upload-artifact@v4
if: always()
with:
name: meson-logs-QuickerSnes9x
path: build/meson-logs/

# Build (QuickerGPGX)
build-QuickerGPGX:
Expand All @@ -156,6 +177,13 @@ jobs:
run: meson setup build -Dbuildtype=release -DuseNCurses=false -Demulator=QuickerGPGX
- name: Building project
run: ninja -C build
- name: Validating examples
run: meson test ValidateExamples -C build
- uses: actions/upload-artifact@v4
if: always()
with:
name: meson-logs-QuickerGPGX
path: build/meson-logs/

# Build (QuickerStella)
build-QuickerStella:
Expand All @@ -178,6 +206,13 @@ jobs:
run: meson setup build -Dbuildtype=release -DuseNCurses=false -Demulator=QuickerStella
- name: Building project
run: ninja -C build
- name: Validating examples
run: meson test ValidateExamples -C build
- uses: actions/upload-artifact@v4
if: always()
with:
name: meson-logs-QuickerStella
path: build/meson-logs/

# Build (Atari2600Hawk)
build-Atari2600Hawk:
Expand Down Expand Up @@ -205,6 +240,13 @@ jobs:
run: meson setup build -Dbuildtype=release -DuseNCurses=false -Demulator=Atari2600Hawk
- name: Building project
run: ninja -C build
- name: Validating examples
run: meson test ValidateExamples -C build
- uses: actions/upload-artifact@v4
if: always()
with:
name: meson-logs-Atari2600Hawk
path: build/meson-logs/

# Build (QuickerSMBC)
build-QuickerSMBC:
Expand All @@ -227,6 +269,13 @@ jobs:
run: meson setup build -Dbuildtype=release -DuseNCurses=false -Demulator=QuickerSMBC
- name: Building project
run: ninja -C build
- name: Validating examples
run: meson test ValidateExamples -C build
- uses: actions/upload-artifact@v4
if: always()
with:
name: meson-logs
path: build/meson-logs/

# Build (QuickerNEORAW)
build-QuickerNEORAW:
Expand All @@ -249,6 +298,13 @@ jobs:
run: meson setup build -Dbuildtype=release -DuseNCurses=false -Demulator=QuickerNEORAW
- name: Building project
run: ninja -C build
- name: Validating examples
run: meson test ValidateExamples -C build
- uses: actions/upload-artifact@v4
if: always()
with:
name: meson-logs-QuickerNEORAW
path: build/meson-logs/

# Build (QuickerRAWGL)
build-QuickerRAWGL:
Expand All @@ -271,6 +327,13 @@ jobs:
run: meson setup build -Dbuildtype=release -DuseNCurses=false -Demulator=QuickerRAWGL
- name: Building project
run: ninja -C build
- name: Validating examples
run: meson test ValidateExamples -C build
- uses: actions/upload-artifact@v4
if: always()
with:
name: meson-logs-QuickerRAWGL
path: build/meson-logs/

# Build (QuickerArkBot)
build-QuickerArkBot:
Expand All @@ -293,6 +356,13 @@ jobs:
run: meson setup build -Dbuildtype=release -DuseNCurses=false -Demulator=QuickerArkBot
- name: Building project
run: ninja -C build
- name: Validating examples
run: meson test ValidateExamples -C build
- uses: actions/upload-artifact@v4
if: always()
with:
name: meson-logs-QuickerArkBot
path: build/meson-logs/

# Build (QuickerMGBA)
build-QuickerMGBA:
Expand All @@ -315,6 +385,13 @@ jobs:
run: meson setup build -Dbuildtype=release -DuseNCurses=false -Demulator=QuickerMGBA
- name: Building project
run: ninja -C build
- name: Validating examples
run: meson test ValidateExamples -C build
- uses: actions/upload-artifact@v4
if: always()
with:
name: meson-logs-QuickerMGBA
path: build/meson-logs/

# Build (QuickerGambatte)
build-QuickerGambatte:
Expand All @@ -337,7 +414,13 @@ jobs:
run: meson setup build -Dbuildtype=release -DuseNCurses=false -Demulator=QuickerGambatte
- name: Building project
run: ninja -C build

- name: Validating examples
run: meson test ValidateExamples -C build
- uses: actions/upload-artifact@v4
if: always()
with:
name: meson-logs-QuickerGambatte
path: build/meson-logs/

# Build (QuickerDSDA)
build-QuickerDSDA:
Expand All @@ -359,4 +442,11 @@ jobs:
- name: Run meson configuration
run: meson setup build -Dbuildtype=release -DuseNCurses=false -Demulator=QuickerDSDA
- name: Building project
run: ninja -C build
run: ninja -C build
- name: Validating examples
run: meson test ValidateExamples -C build
- uses: actions/upload-artifact@v4
if: always()
with:
name: meson-logs-QuickerDSDA
path: build/meson-logs/
33 changes: 15 additions & 18 deletions emulators/atari2600Hawk/atari2600Hawk.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#pragma once

#include <a2600HawkInstance.hpp>
#include <emulator.hpp>
#include <jaffarCommon/deserializers/base.hpp>
#include <jaffarCommon/hash.hpp>
#include <jaffarCommon/json.hpp>
#include <jaffarCommon/logger.hpp>
#include <jaffarCommon/serializers/base.hpp>
#include <mutex>
#include <emulator.hpp>
#include <a2600HawkInstance.hpp>

namespace jaffarPlus
{
Expand All @@ -17,25 +17,23 @@ namespace emulator

class Atari2600Hawk final : public Emulator
{
public:

public:
static std::string getName() { return "Atari2600Hawk"; }

// Constructor must only do configuration parsing
Atari2600Hawk(const nlohmann::json &config)
: Emulator(config)
Atari2600Hawk(const nlohmann::json& config) : Emulator(config)
{
// Parsing rom file path
_romFilePath = jaffarCommon::json::getString(config, "Rom File Path");

// For testing purposes, the rom file path can be overriden by environment variables
if (auto *value = std::getenv("JAFFAR_Atari2600Hawk_OVERRIDE_ROM_FILE_PATH")) _romFilePath = std::string(value);
if (auto* value = std::getenv("JAFFAR_Atari2600Hawk_OVERRIDE_ROM_FILE_PATH")) _romFilePath = std::string(value);

// Parsing rom file SHA1
_romFileSHA1 = jaffarCommon::json::getString(config, "Rom File SHA1");

// For testing purposes, the rom file SHA1 can be overriden by environment variables
if (auto *value = std::getenv("JAFFAR_Atari2600Hawk_OVERRIDE_ROM_FILE_SHA1")) _romFileSHA1 = std::string(value);
if (auto* value = std::getenv("JAFFAR_Atari2600Hawk_OVERRIDE_ROM_FILE_SHA1")) _romFileSHA1 = std::string(value);

// Creating internal emulator instance
_Atari2600Hawk = std::make_unique<libA2600Hawk::EmuInstance>(config);
Expand Down Expand Up @@ -63,32 +61,32 @@ class Atari2600Hawk final : public Emulator
}

// State advancing function
void advanceStateImpl(const jaffar::input_t &input) override
void advanceStateImpl(const jaffar::input_t& input) override
{
_Atari2600Hawk->advanceState(input);

// Retreiving workram
for (size_t i = 0; i < 128; i++) _workRam[i] = _Atari2600Hawk->getWorkRamByte(i);
}

__INLINE__ void serializeState(jaffarCommon::serializer::Base &serializer) const override
__INLINE__ void serializeState(jaffarCommon::serializer::Base& serializer) const override
{
_Atari2600Hawk->serializeState(serializer);
serializer.pushContiguous(_workRam, 128);
};

__INLINE__ void deserializeState(jaffarCommon::deserializer::Base &deserializer) override
__INLINE__ void deserializeState(jaffarCommon::deserializer::Base& deserializer) override
{
_Atari2600Hawk->deserializeState(deserializer);
deserializer.popContiguous(_workRam, 128);
};

__INLINE__ void printInfo() const override {}

property_t getProperty(const std::string &propertyName) const override
property_t getProperty(const std::string& propertyName) const override
{
uint64_t ramPtr = (uint64_t)_workRam;
if (propertyName == "RAM") return property_t((uint8_t *)ramPtr, 128);
if (propertyName == "RAM") return property_t((uint8_t*)ramPtr, 128);

JAFFAR_THROW_LOGIC("Property name: '%s' not found in emulator '%s'", propertyName.c_str(), getName().c_str());
}
Expand All @@ -105,13 +103,13 @@ class Atari2600Hawk final : public Emulator

__INLINE__ void updateRendererState(const size_t stepIdx, const std::string input) override {}

__INLINE__ void serializeRendererState(jaffarCommon::serializer::Base &serializer) const override
__INLINE__ void serializeRendererState(jaffarCommon::serializer::Base& serializer) const override
{
serializeState(serializer);
serializer.pushContiguous(_Atari2600Hawk->getVideoBuffer(), _Atari2600Hawk->getVideoBufferSize());
}

__INLINE__ void deserializeRendererState(jaffarCommon::deserializer::Base &deserializer) override
__INLINE__ void deserializeRendererState(jaffarCommon::deserializer::Base& deserializer) override
{
deserializeState(deserializer);
deserializer.popContiguous(_Atari2600Hawk->getVideoBuffer(), _Atari2600Hawk->getVideoBufferSize());
Expand All @@ -127,10 +125,9 @@ class Atari2600Hawk final : public Emulator
__INLINE__ void showRender() override { _Atari2600Hawk->updateRenderer(); }

// Function to get a reference to the input parser from the base emulator
jaffar::InputParser *getInputParser() const override { return _Atari2600Hawk->getInputParser(); }

private:
jaffar::InputParser* getInputParser() const override { return _Atari2600Hawk->getInputParser(); }

private:
std::unique_ptr<libA2600Hawk::EmuInstance> _Atari2600Hawk;

std::string _romFilePath;
Expand Down
Loading
Loading