Skip to content
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

Preliminary support for Aleck64 #1758

Draft
wants to merge 23 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
646f916
mame2bml: print list of drivers used to generate bml
LukeUsher Jan 6, 2025
5ce110b
arcade: show machine type in game browser
LukeUsher Jan 7, 2025
eea0922
arcade: import aleck64 romlist
LukeUsher Jan 7, 2025
829a8f0
mia: add support for aleck64 arcade roms
LukeUsher Jan 7, 2025
52b1a23
arcade: update database
LukeUsher Jan 8, 2025
fb5ff07
n64: preliminary support for aleck64 arcade system
LukeUsher Jan 8, 2025
fcd9be0
cleanup/debug print removal
LukeUsher Jan 8, 2025
4e851c9
aleck64: add support for Eleven Beat
LukeUsher Jan 8, 2025
0ebc384
aleck64: fix unity builds
LukeUsher Jan 8, 2025
ced8beb
aleck64: fix legacy build
LukeUsher Jan 8, 2025
d8a69e6
aleck64: set n64 core options correctly
LukeUsher Jan 8, 2025
4479304
aleck64: add configs for all games that don't need special hardware
LukeUsher Jan 9, 2025
c68fd72
arcade: fix a crash when running multiple arcade games in one session
LukeUsher Jan 9, 2025
7dadc07
arcade: resolve parent relationships when loading arcade roms
LukeUsher Jan 10, 2025
ae119f2
mame2bml: only write a parent attribute if the game has a parent
LukeUsher Jan 10, 2025
8059b8d
aleck64: update CMakeLists.txt
LukeUsher Jan 10, 2025
aeef2d8
aleck64: mahjong input support (fixes the two Hi Pai games)
LukeUsher Jan 10, 2025
1edf83b
Apply suggestions from code review
LukeUsher Jan 11, 2025
b5be51c
aleck64: fix build after merging changes
LukeUsher Jan 11, 2025
dd737b1
aleck64: swap prints for debug()
LukeUsher Jan 11, 2025
4a47694
aleck64: alignment/formatting
LukeUsher Jan 11, 2025
18094a6
aleck64: reduce duplication, partial support for mtetrisc
LukeUsher Jan 16, 2025
38f0220
aleck64: add serialization
LukeUsher Jan 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions ares/n64/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ares_add_sources(
cpu/cpu.cpp
rsp/rsp.cpp
rdp/rdp.cpp
aleck64/aleck64.cpp
)

target_enable_feature(ares "N64 Vulkan rendering with paraLLEl-RDP" VULKAN)
Expand Down Expand Up @@ -61,6 +62,25 @@ ares_add_sources(
ai/serialization.cpp
)

ares_add_sources(
CORE #
n64
INCLUDED #
aleck64/aleck64.hpp
aleck64/controls.cpp
aleck64/io.cpp
aleck64/game-config/11beat.hpp
aleck64/game-config/doncdoon.hpp
aleck64/game-config/kurufev.hpp
aleck64/game-config/mayjin3.hpp
aleck64/game-config/starsldr.hpp
aleck64/game-config/twrshaft.hpp
aleck64/game-config/vivdolls.hpp
aleck64/game-config/hipai.hpp
aleck64/game-config/hipai2.hpp
aleck64/game-config/srmvs.hpp
)

ares_add_sources(
CORE #
n64
Expand Down Expand Up @@ -95,6 +115,14 @@ ares_add_sources(
controller/port.hpp
)

ares_add_sources(
CORE #
n64
INCLUDED #
controller/aleck64/aleck64.cpp
controller/aleck64/aleck64.hpp
)

ares_add_sources(
CORE #
n64
Expand Down
2 changes: 2 additions & 0 deletions ares/n64/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ares.objects += ares-n64-rdram
ares.objects += ares-n64-cpu
ares.objects += ares-n64-rsp
ares.objects += ares-n64-rdp
ares.objects += ares-n64-aleck64

$(object.path)/ares-n64-memory.o: $(ares.path)/n64/memory/memory.cpp
$(object.path)/ares-n64-system.o: $(ares.path)/n64/system/system.cpp
Expand All @@ -37,6 +38,7 @@ $(object.path)/ares-n64-rdram.o: $(ares.path)/n64/rdram/rdram.cpp
$(object.path)/ares-n64-cpu.o: $(ares.path)/n64/cpu/cpu.cpp
$(object.path)/ares-n64-rsp.o: $(ares.path)/n64/rsp/rsp.cpp
$(object.path)/ares-n64-rdp.o: $(ares.path)/n64/rdp/rdp.cpp
$(object.path)/ares-n64-aleck64.o: $(ares.path)/n64/aleck64/aleck64.cpp

ifeq ($(vulkan),true)
ifeq ($(platform),macos)
Expand Down
60 changes: 60 additions & 0 deletions ares/n64/aleck64/aleck64.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#include <n64/n64.hpp>

namespace ares::Nintendo64 {
Aleck64 aleck64;

#include "io.cpp"
#include "controls.cpp"

#include "game-config/11beat.hpp"
#include "game-config/starsldr.hpp"
#include "game-config/doncdoon.hpp"
#include "game-config/kurufev.hpp"
#include "game-config/mayjin3.hpp"
#include "game-config/vivdolls.hpp"
#include "game-config/twrshaft.hpp"
#include "game-config/hipai.hpp"
#include "game-config/hipai2.hpp"
#include "game-config/srmvs.hpp"

auto Aleck64::load(Node::Object parent) -> void {
sdram.allocate(4_MiB);
controls.load(parent);
gameConfig.reset();
dipSwitchNode = parent->append<Node::Object>("DIP Switches");
}

auto Aleck64::unload() -> void {
sdram.reset();
}

auto Aleck64::save() -> void {

}

auto Aleck64::power(bool reset) -> void {
if(!reset) {
dipSwitch[0] = 0xffff'ffff;
dipSwitch[1] = 0xffff'ffff;

//NOTE: We can't do this at 'load' time because cartridges are not attached yet...
auto name = cartridge.pak->attribute("name");

if(name == "11beat" ) gameConfig = new _11beat();
if(name == "starsldr") gameConfig = new starsldr();
if(name == "doncdoon") gameConfig = new doncdoon();
if(name == "kurufev" ) gameConfig = new kurufev();
if(name == "mayjin3" ) gameConfig = new mayjin3();
if(name == "vivdolls") gameConfig = new vivdolls();
if(name == "twrshaft") gameConfig = new twrshaft();
if(name == "hipai" ) gameConfig = new hipai();
if(name == "hipai2" ) gameConfig = new hipai2();
if(name == "srmvs" ) gameConfig = new srmvs();
if(name == "srmvsa" ) gameConfig = new srmvs();

if(gameConfig) gameConfig->dipSwitches(dipSwitchNode);

sdram.fill();
}
}
}
134 changes: 134 additions & 0 deletions ares/n64/aleck64/aleck64.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
struct Aleck64 : Memory::RCP<Aleck64> {
Node::Object dipSwitchNode;

struct Writable : public Memory::Writable {
Aleck64& self;

Writable(Aleck64& self) : self(self) {}

template<u32 Size>
auto writeBurst(u32 address, u32 *value, const char *peripheral) -> void {
if (address >= size) return;
LukeUsher marked this conversation as resolved.
Show resolved Hide resolved
Memory::Writable::write<Word>(address | 0x00, value[0]);
Memory::Writable::write<Word>(address | 0x04, value[1]);
Memory::Writable::write<Word>(address | 0x08, value[2]);
Memory::Writable::write<Word>(address | 0x0c, value[3]);
if (Size == ICache) {
Memory::Writable::write<Word>(address | 0x10, value[4]);
Memory::Writable::write<Word>(address | 0x14, value[5]);
Memory::Writable::write<Word>(address | 0x18, value[6]);
Memory::Writable::write<Word>(address | 0x1c, value[7]);
}
}

template<u32 Size>
auto readBurst(u32 address, u32 *value, const char *peripheral) -> void {
if (address >= size) {
LukeUsher marked this conversation as resolved.
Show resolved Hide resolved
value[0] = value[1] = value[2] = value[3] = 0;
if (Size == ICache)
value[4] = value[5] = value[6] = value[7] = 0;
return;
}
value[0] = Memory::Writable::read<Word>(address | 0x00);
value[1] = Memory::Writable::read<Word>(address | 0x04);
value[2] = Memory::Writable::read<Word>(address | 0x08);
value[3] = Memory::Writable::read<Word>(address | 0x0c);
if (Size == ICache) {
value[4] = Memory::Writable::read<Word>(address | 0x10);
value[5] = Memory::Writable::read<Word>(address | 0x14);
value[6] = Memory::Writable::read<Word>(address | 0x18);
value[7] = Memory::Writable::read<Word>(address | 0x1c);
}
}

} sdram{*this};
auto load(Node::Object) -> void;
auto unload() -> void;
auto power(bool reset) -> void;
auto save() -> void;
auto applyGameSpecificSettings(string name) -> void;

//io.cpp
auto readWord(u32 address, Thread& thread) -> u32;
auto writeWord(u32 address, u32 data, Thread& thread) -> void;

auto readPort1() -> u32;
auto readPort2() -> u32;
auto readPort3() -> u32;
auto writePort3(n32 data) -> void;

struct Controls {
Aleck64& self;
Node::Object node;

Node::Input::Button service;
Node::Input::Button test;

Node::Input::Axis p1x;
Node::Input::Axis p1y;
Node::Input::Button p1up;
Node::Input::Button p1down;
Node::Input::Button p1left;
Node::Input::Button p1right;
Node::Input::Button p1[9];
Node::Input::Button p1start;
Node::Input::Button p1coin;

Node::Input::Axis p2x;
Node::Input::Axis p2y;
Node::Input::Button p2up;
Node::Input::Button p2down;
Node::Input::Button p2left;
Node::Input::Button p2right;
Node::Input::Button p2[9];
Node::Input::Button p2start;
Node::Input::Button p2coin;

Node::Input::Button mahjongA;
Node::Input::Button mahjongB;
Node::Input::Button mahjongC;
Node::Input::Button mahjongD;
Node::Input::Button mahjongE;
Node::Input::Button mahjongF;
Node::Input::Button mahjongG;
Node::Input::Button mahjongH;
Node::Input::Button mahjongI;
Node::Input::Button mahjongJ;
Node::Input::Button mahjongK;
Node::Input::Button mahjongL;
Node::Input::Button mahjongM;
Node::Input::Button mahjongN;
Node::Input::Button mahjongKan;
Node::Input::Button mahjongPon;
Node::Input::Button mahjongChi;
Node::Input::Button mahjongReach;
Node::Input::Button mahjongRon;

//controls.cpp
auto load(Node::Object) -> void;
auto poll() -> void;

auto controllerButton(int playerIndex, string button) -> bool;
auto controllerAxis(int playerIndex, string axis) -> s64;
auto ioPortControls(int port) -> n32;
auto mahjong(n8 row) -> n8;

} controls{*this};

n8 dipSwitch[2];

struct GameConfig {
virtual ~GameConfig() = default;
virtual auto dipSwitches(Node::Object parent) -> void = 0;

virtual auto controllerButton(int playerIndex, string button) -> bool { return 0; }
virtual auto controllerAxis(int playerIndex, string axis) -> s64 { return 0; };
virtual auto ioPortControls(int port) -> n32 { return 0xffff'ffff; }
virtual auto readExpansionPort() -> u32 { return 0xffff'ffff; }
virtual auto writeExpansionPort(n32 data) -> void {};
};

shared_pointer<GameConfig> gameConfig;
};

extern Aleck64 aleck64;
Loading
Loading