From 0a34ef8e0b5efa43672de8e584b959cb3bf157ed Mon Sep 17 00:00:00 2001
From: windwakr <284886+windwakr@users.noreply.github.com>
Date: Wed, 4 Oct 2023 17:05:01 -0400
Subject: [PATCH] Slot2: Add Sega Card Reader(HCV-1000)
---
desmume/src/Makefile.am | 1 +
desmume/src/addons/slot2_hcv1000.cpp | 81 +++++++++++++++++++
desmume/src/frontend/interface/meson.build | 2 +-
.../windows/DeSmuME_Interface.vcxproj | 1 +
.../windows/DeSmuME_Interface.vcxproj.filters | 3 +
desmume/src/frontend/posix/Makefile.am | 2 +-
desmume/src/frontend/posix/meson.build | 2 +-
desmume/src/frontend/windows/DeSmuME.vcxproj | 1 +
.../frontend/windows/DeSmuME.vcxproj.filters | 3 +
.../src/frontend/windows/gbaslot_config.cpp | 68 +++++++++++++++-
desmume/src/frontend/windows/gbaslot_config.h | 3 +-
desmume/src/frontend/windows/inputdx.cpp | 30 ++++++-
desmume/src/frontend/windows/inputdx.h | 8 +-
desmume/src/frontend/windows/main.cpp | 8 +-
desmume/src/frontend/windows/resource.h | 5 +-
desmume/src/frontend/windows/resources.rc | 11 +++
desmume/src/slot2.cpp | 7 +-
desmume/src/slot2.h | 5 +-
18 files changed, 229 insertions(+), 12 deletions(-)
create mode 100644 desmume/src/addons/slot2_hcv1000.cpp
diff --git a/desmume/src/Makefile.am b/desmume/src/Makefile.am
index f3185e918..b17d4df7f 100644
--- a/desmume/src/Makefile.am
+++ b/desmume/src/Makefile.am
@@ -95,6 +95,7 @@ libdesmume_a_SOURCES = \
addons/slot2_none.cpp \
addons/slot2_rumblepak.cpp \
addons/slot2_guitarGrip.cpp \
+ addons/slot2_hcv1000.cpp \
addons/slot2_expMemory.cpp \
addons/slot2_piano.cpp \
addons/slot2_passme.cpp \
diff --git a/desmume/src/addons/slot2_hcv1000.cpp b/desmume/src/addons/slot2_hcv1000.cpp
new file mode 100644
index 000000000..8135fe003
--- /dev/null
+++ b/desmume/src/addons/slot2_hcv1000.cpp
@@ -0,0 +1,81 @@
+//HCV-1000 emulation code adapted from GBE+: https://github.com/shonumi/gbe-plus
+
+/*
+ Modifications Copyright (C) 2023 DeSmuME team
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with the this software. If not, see .
+*/
+
+#include
+
+#include "../slot2.h"
+
+u8 hcv1000_cnt;
+char hcv1000_data[16];
+
+class Slot2_HCV1000 : public ISlot2Interface
+{
+public:
+
+ virtual Slot2Info const* info()
+ {
+ static Slot2InfoSimple info("Sega Card Reader", "Sega Card Reader(HCV-1000) add-on", 0x09);
+ return &info;
+ }
+
+ virtual bool init()
+ {
+ hcv1000_cnt = 0;
+ memset(hcv1000_data, 0x5F, 16);
+
+ return TRUE;
+ }
+
+ virtual void writeByte(u8 PROCNUM, u32 addr, u8 val)
+ {
+ if (addr == 0xA000000) { hcv1000_cnt = (val & 0x83); }
+ }
+
+ virtual u8 readByte(u8 PROCNUM, u32 addr)
+ {
+ u8 slot_byte = 0xFF;
+ //Reading these cart addresses is for detection
+ if (addr < 0x8020000)
+ {
+ u8 data = 0xF0 | ((addr & 0x1F) >> 1);
+ slot_byte = (addr & 0x1) ? 0xFD : data;
+ }
+
+ //HCV_CNT
+ else if (addr == 0xA000000) { slot_byte = hcv1000_cnt; }
+
+ //HCV_DATA
+ else if ((addr >= 0xA000010) && (addr <= 0xA00001F))
+ {
+ slot_byte = (u8)hcv1000_data[addr & 0xF];
+ }
+
+ return slot_byte;
+ }
+
+ virtual u16 readWord(u8 PROCNUM, u32 addr) { return 0xFDFD; };
+ virtual u32 readLong(u8 PROCNUM, u32 addr) { return 0xFDFDFDFD; };
+};
+
+ISlot2Interface* construct_Slot2_HCV1000() { return new Slot2_HCV1000(); }
+
+void HCV1000_setReady()
+{
+ hcv1000_cnt &= ~0x80;
+}
diff --git a/desmume/src/frontend/interface/meson.build b/desmume/src/frontend/interface/meson.build
index 1a6328a1a..6a62fbb2e 100644
--- a/desmume/src/frontend/interface/meson.build
+++ b/desmume/src/frontend/interface/meson.build
@@ -109,7 +109,7 @@ libdesmume_src += [
'../../utils/tinyxml/tinyxmlerror.cpp',
'../../utils/tinyxml/tinyxmlparser.cpp',
'../../utils/colorspacehandler/colorspacehandler.cpp',
- '../../addons/slot2_auto.cpp', '../../addons/slot2_mpcf.cpp', '../../addons/slot2_paddle.cpp', '../../addons/slot2_gbagame.cpp', '../../addons/slot2_none.cpp', '../../addons/slot2_rumblepak.cpp', '../../addons/slot2_guitarGrip.cpp', '../../addons/slot2_expMemory.cpp', '../../addons/slot2_piano.cpp', '../../addons/slot2_passme.cpp', '../../addons/slot1_none.cpp', '../../addons/slot1_r4.cpp', '../../addons/slot1_retail_nand.cpp', '../../addons/slot1_retail_auto.cpp', '../../addons/slot1_retail_mcrom.cpp', '../../addons/slot1_retail_mcrom_debug.cpp', '../../addons/slot1comp_mc.cpp', '../../addons/slot1comp_rom.cpp', '../../addons/slot1comp_protocol.cpp',
+ '../../addons/slot2_auto.cpp', '../../addons/slot2_mpcf.cpp', '../../addons/slot2_paddle.cpp', '../../addons/slot2_gbagame.cpp', '../../addons/slot2_none.cpp', '../../addons/slot2_rumblepak.cpp', '../../addons/slot2_guitarGrip.cpp', '../../addons/slot2_hcv1000.cpp', '../../addons/slot2_expMemory.cpp', '../../addons/slot2_piano.cpp', '../../addons/slot2_passme.cpp', '../../addons/slot1_none.cpp', '../../addons/slot1_r4.cpp', '../../addons/slot1_retail_nand.cpp', '../../addons/slot1_retail_auto.cpp', '../../addons/slot1_retail_mcrom.cpp', '../../addons/slot1_retail_mcrom_debug.cpp', '../../addons/slot1comp_mc.cpp', '../../addons/slot1comp_rom.cpp', '../../addons/slot1comp_protocol.cpp',
'../../cheatSystem.cpp',
'../../texcache.cpp', '../../rasterize.cpp',
'../../metaspu/metaspu.cpp',
diff --git a/desmume/src/frontend/interface/windows/DeSmuME_Interface.vcxproj b/desmume/src/frontend/interface/windows/DeSmuME_Interface.vcxproj
index 35638797a..ab87e284e 100644
--- a/desmume/src/frontend/interface/windows/DeSmuME_Interface.vcxproj
+++ b/desmume/src/frontend/interface/windows/DeSmuME_Interface.vcxproj
@@ -268,6 +268,7 @@
+
diff --git a/desmume/src/frontend/interface/windows/DeSmuME_Interface.vcxproj.filters b/desmume/src/frontend/interface/windows/DeSmuME_Interface.vcxproj.filters
index db90b8e93..cb3248c43 100755
--- a/desmume/src/frontend/interface/windows/DeSmuME_Interface.vcxproj.filters
+++ b/desmume/src/frontend/interface/windows/DeSmuME_Interface.vcxproj.filters
@@ -132,6 +132,9 @@
addons
+
+ addons
+
addons
diff --git a/desmume/src/frontend/posix/Makefile.am b/desmume/src/frontend/posix/Makefile.am
index 59b0fb3bc..4329a89e7 100644
--- a/desmume/src/frontend/posix/Makefile.am
+++ b/desmume/src/frontend/posix/Makefile.am
@@ -98,7 +98,7 @@ libdesmume_a_SOURCES = \
../../utils/tinyxml/tinyxmlparser.cpp \
../../utils/glcorearb.h \
../../utils/colorspacehandler/colorspacehandler.cpp ../../utils/colorspacehandler/colorspacehandler.h \
- ../../addons/slot2_auto.cpp ../../addons/slot2_mpcf.cpp ../../addons/slot2_paddle.cpp ../../addons/slot2_gbagame.cpp ../../addons/slot2_none.cpp ../../addons/slot2_rumblepak.cpp ../../addons/slot2_guitarGrip.cpp ../../addons/slot2_expMemory.cpp ../../addons/slot2_piano.cpp ../../addons/slot2_passme.cpp ../../addons/slot1_none.cpp ../../addons/slot1_r4.cpp ../../addons/slot1_retail_nand.cpp ../../addons/slot1_retail_auto.cpp ../../addons/slot1_retail_mcrom.cpp ../../addons/slot1_retail_mcrom_debug.cpp ../../addons/slot1comp_mc.cpp ../../addons/slot1comp_mc.h ../../addons/slot1comp_rom.h ../../addons/slot1comp_rom.cpp ../../addons/slot1comp_protocol.h ../../addons/slot1comp_protocol.cpp \
+ ../../addons/slot2_auto.cpp ../../addons/slot2_mpcf.cpp ../../addons/slot2_paddle.cpp ../../addons/slot2_gbagame.cpp ../../addons/slot2_none.cpp ../../addons/slot2_rumblepak.cpp ../../addons/slot2_guitarGrip.cpp ../../addons/slot2_hcv1000.cpp ../../addons/slot2_expMemory.cpp ../../addons/slot2_piano.cpp ../../addons/slot2_passme.cpp ../../addons/slot1_none.cpp ../../addons/slot1_r4.cpp ../../addons/slot1_retail_nand.cpp ../../addons/slot1_retail_auto.cpp ../../addons/slot1_retail_mcrom.cpp ../../addons/slot1_retail_mcrom_debug.cpp ../../addons/slot1comp_mc.cpp ../../addons/slot1comp_mc.h ../../addons/slot1comp_rom.h ../../addons/slot1comp_rom.cpp ../../addons/slot1comp_protocol.h ../../addons/slot1comp_protocol.cpp \
../../cheatSystem.cpp ../../cheatSystem.h \
../../texcache.cpp ../../texcache.h ../../rasterize.cpp ../../rasterize.h \
../../metaspu/metaspu.cpp ../../metaspu/metaspu.h \
diff --git a/desmume/src/frontend/posix/meson.build b/desmume/src/frontend/posix/meson.build
index 901c4defc..89e0e4bef 100644
--- a/desmume/src/frontend/posix/meson.build
+++ b/desmume/src/frontend/posix/meson.build
@@ -104,7 +104,7 @@ libdesmume_src = [
'../../utils/tinyxml/tinyxmlerror.cpp',
'../../utils/tinyxml/tinyxmlparser.cpp',
'../../utils/colorspacehandler/colorspacehandler.cpp',
- '../../addons/slot2_auto.cpp', '../../addons/slot2_mpcf.cpp', '../../addons/slot2_paddle.cpp', '../../addons/slot2_gbagame.cpp', '../../addons/slot2_none.cpp', '../../addons/slot2_rumblepak.cpp', '../../addons/slot2_guitarGrip.cpp', '../../addons/slot2_expMemory.cpp', '../../addons/slot2_piano.cpp', '../../addons/slot2_passme.cpp', '../../addons/slot1_none.cpp', '../../addons/slot1_r4.cpp', '../../addons/slot1_retail_nand.cpp', '../../addons/slot1_retail_auto.cpp', '../../addons/slot1_retail_mcrom.cpp', '../../addons/slot1_retail_mcrom_debug.cpp', '../../addons/slot1comp_mc.cpp', '../../addons/slot1comp_rom.cpp', '../../addons/slot1comp_protocol.cpp',
+ '../../addons/slot2_auto.cpp', '../../addons/slot2_mpcf.cpp', '../../addons/slot2_paddle.cpp', '../../addons/slot2_gbagame.cpp', '../../addons/slot2_none.cpp', '../../addons/slot2_rumblepak.cpp', '../../addons/slot2_guitarGrip.cpp', '../../addons/slot2_hcv1000.cpp', '../../addons/slot2_expMemory.cpp', '../../addons/slot2_piano.cpp', '../../addons/slot2_passme.cpp', '../../addons/slot1_none.cpp', '../../addons/slot1_r4.cpp', '../../addons/slot1_retail_nand.cpp', '../../addons/slot1_retail_auto.cpp', '../../addons/slot1_retail_mcrom.cpp', '../../addons/slot1_retail_mcrom_debug.cpp', '../../addons/slot1comp_mc.cpp', '../../addons/slot1comp_rom.cpp', '../../addons/slot1comp_protocol.cpp',
'../../cheatSystem.cpp',
'../../texcache.cpp', '../../rasterize.cpp',
'../../metaspu/metaspu.cpp',
diff --git a/desmume/src/frontend/windows/DeSmuME.vcxproj b/desmume/src/frontend/windows/DeSmuME.vcxproj
index abf978664..bd4484362 100644
--- a/desmume/src/frontend/windows/DeSmuME.vcxproj
+++ b/desmume/src/frontend/windows/DeSmuME.vcxproj
@@ -65,6 +65,7 @@
+
diff --git a/desmume/src/frontend/windows/DeSmuME.vcxproj.filters b/desmume/src/frontend/windows/DeSmuME.vcxproj.filters
index 20bfe9dc2..3e18bf156 100644
--- a/desmume/src/frontend/windows/DeSmuME.vcxproj.filters
+++ b/desmume/src/frontend/windows/DeSmuME.vcxproj.filters
@@ -930,6 +930,9 @@
frontend\Windows
+
+ addons
+
diff --git a/desmume/src/frontend/windows/gbaslot_config.cpp b/desmume/src/frontend/windows/gbaslot_config.cpp
index 75bb02053..5797b67c9 100644
--- a/desmume/src/frontend/windows/gbaslot_config.cpp
+++ b/desmume/src/frontend/windows/gbaslot_config.cpp
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2009-2016 DeSmuME team
+ Copyright (C) 2009-2023 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -36,18 +36,21 @@ u8 last_type = 0;
char tmp_cflash_filename[MAX_PATH] = { 0 };
char tmp_cflash_path[MAX_PATH] = { 0 };
char tmp_gbagame_filename[MAX_PATH] = { 0 };
+TCHAR tmp_hcv1000_barcode[17] = { 0 };
ADDON_CFLASH_MODE tmp_CFlashMode = ADDON_CFLASH_MODE_RomPath;
HWND OKbutton = NULL;
bool _OKbutton = false;
SGuitar tmp_Guitar;
SPiano tmp_Piano;
SPaddle tmp_Paddle;
+SHCV1000 tmp_HCV1000;
//these are the remembered preset values for directory and filename
//they are named very verbosely to distinguish them from the currently-configured values in addons.cpp
std::string win32_CFlash_cfgDirectory, win32_CFlash_cfgFileName;
UINT win32_CFlash_cfgMode;
std::string win32_GBA_cfgRomPath;
+std::string win32_HCV1000_barcode;
INT_PTR CALLBACK GbaSlotNone(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam)
{
@@ -263,6 +266,54 @@ INT_PTR CALLBACK GbaSlotPaddle(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam
return FALSE;
}
+INT_PTR CALLBACK GbaSlotHCV1000(HWND dialog, UINT msg, WPARAM wparam, LPARAM lparam)
+{
+ int which = 0;
+
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ _OKbutton = TRUE;
+ SendDlgItemMessage(dialog, IDC_HCVSCAN, WM_USER + 44, tmp_HCV1000.SCANKEY, 0);
+ SendDlgItemMessage(dialog, IDC_HCVBARCODE, EM_SETLIMITTEXT, 16, 0);
+ SendDlgItemMessage(dialog, IDC_HCVBARCODE, EM_SETSEL, 0, 16);
+ SetWindowText(GetDlgItem(dialog, IDC_HCVBARCODE), tmp_hcv1000_barcode);
+
+ return TRUE;
+
+ case WM_USER + 46:
+ SendDlgItemMessage(dialog, IDC_HCVSCAN, WM_USER + 44, tmp_HCV1000.SCANKEY, 0);
+ return TRUE;
+
+ case WM_USER + 43:
+ //MessageBox(hDlg,"USER+43 CAUGHT","moo",MB_OK);
+ which = GetDlgCtrlID((HWND)lparam);
+ switch (which)
+ {
+ case IDC_HCVSCAN:
+ tmp_HCV1000.SCANKEY = wparam;
+
+ break;
+ }
+
+ SendDlgItemMessage(dialog, IDC_HCVSCAN, WM_USER + 44, tmp_HCV1000.SCANKEY, 0);
+ PostMessage(dialog, WM_NEXTDLGCTL, 0, 0);
+ return true;
+
+ case WM_COMMAND:
+ case EN_UPDATE:
+ switch (LOWORD(wparam))
+ {
+ case IDC_HCVBARCODE:
+ GetWindowText(GetDlgItem(dialog, IDC_HCVBARCODE), tmp_hcv1000_barcode, 16);
+
+ return FALSE;
+ }
+ break;
+ }
+ return FALSE;
+}
+
INT_PTR CALLBACK GbaSlotRumblePak(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam)
{
switch(msg)
@@ -478,6 +529,7 @@ u32 GBAslot_IDDs[NDS_SLOT2_COUNT] = {
IDD_GBASLOT_PIANO,
IDD_GBASLOT_PADDLE, //paddle
IDD_GBASLOT_NONE, //PassME
+ IDD_GBASLOT_HCV1000, //HCV-1000
};
DLGPROC GBAslot_Procs[NDS_SLOT2_COUNT] = {
@@ -490,7 +542,8 @@ DLGPROC GBAslot_Procs[NDS_SLOT2_COUNT] = {
GbaSlotNone, //expmem
GbaSlotPiano,
GbaSlotPaddle,
- GbaSlotNone // PassME
+ GbaSlotNone, // PassME
+ GbaSlotHCV1000, //HCV-1000
};
@@ -566,9 +619,11 @@ void GBAslotDialog(HWND hwnd)
strcpy(tmp_cflash_filename, win32_CFlash_cfgFileName.c_str());
strcpy(tmp_cflash_path, win32_CFlash_cfgDirectory.c_str());
strcpy(tmp_gbagame_filename, win32_GBA_cfgRomPath.c_str());
+ strcpy(tmp_hcv1000_barcode, win32_HCV1000_barcode.c_str());
memcpy(&tmp_Guitar, &Guitar, sizeof(Guitar));
memcpy(&tmp_Piano, &Piano, sizeof(Piano));
memcpy(&tmp_Paddle, &Paddle, sizeof(Paddle));
+ memcpy(&tmp_HCV1000, &HCV1000, sizeof(HCV1000));
tmp_CFlashMode = CFlash_Mode;
_OKbutton = false;
@@ -633,6 +688,14 @@ void GBAslotDialog(HWND hwnd)
break;
case NDS_SLOT2_PASSME:
break;
+ case NDS_SLOT2_HCV1000:
+ win32_HCV1000_barcode = tmp_hcv1000_barcode;
+ memcpy(&HCV1000, &tmp_HCV1000, sizeof(tmp_HCV1000));
+ memset(hcv1000_data, 0x5F, 16);
+ memcpy(hcv1000_data, win32_HCV1000_barcode.c_str(), (win32_HCV1000_barcode.length() <= 16) ? win32_HCV1000_barcode.length() : 16);
+ WritePrivateProfileString("Slot2.HCV1000", "barcode", tmp_hcv1000_barcode, IniName);
+ WritePrivateProfileInt("Slot2.HCV1000", "scankey", HCV1000.SCANKEY, IniName);
+ break;
default:
return;
}
@@ -644,6 +707,7 @@ void GBAslotDialog(HWND hwnd)
Guitar.Enabled = (slot2_GetCurrentType() == NDS_SLOT2_GUITARGRIP)?true:false;
Piano.Enabled = (slot2_GetCurrentType() == NDS_SLOT2_EASYPIANO)?true:false;
Paddle.Enabled = (slot2_GetCurrentType() == NDS_SLOT2_PADDLE)?true:false;
+ HCV1000.Enabled = (slot2_GetCurrentType() == NDS_SLOT2_HCV1000)?true:false;
}
}
diff --git a/desmume/src/frontend/windows/gbaslot_config.h b/desmume/src/frontend/windows/gbaslot_config.h
index ccc7937a2..f06140d7c 100644
--- a/desmume/src/frontend/windows/gbaslot_config.h
+++ b/desmume/src/frontend/windows/gbaslot_config.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2009-2015 DeSmuME team
+ Copyright (C) 2009-2023 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
extern std::string win32_CFlash_cfgDirectory, win32_CFlash_cfgFileName;
extern UINT win32_CFlash_cfgMode;
extern std::string win32_GBA_cfgRomPath;
+extern std::string win32_HCV1000_barcode;
extern void GBAslotDialog(HWND hwnd);
diff --git a/desmume/src/frontend/windows/inputdx.cpp b/desmume/src/frontend/windows/inputdx.cpp
index 9772aa785..c6a6b40a9 100644
--- a/desmume/src/frontend/windows/inputdx.cpp
+++ b/desmume/src/frontend/windows/inputdx.cpp
@@ -3,7 +3,7 @@
licensed under the terms supplied at the end of this file (for the terms are very long!)
Differences from that baseline version are:
- Copyright (C) 2009-2019 DeSmuME team
+ Copyright (C) 2009-2023 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -258,6 +258,9 @@ SPiano DefaultPiano = { false, 'Z', 'S', 'X', 'D', 'C', 'V', 'G', 'B', 'H', 'N',
SPaddle Paddle;
SPaddle DefaultPaddle = { false, 'K', 'L' };
+SHCV1000 HCV1000;
+SHCV1000 DefaultHCV1000 = { false, 'L'};
+
bool killStylusTopScreen = false;
bool killStylusOffScreen = false;
bool allowUpAndDown = false;
@@ -390,6 +393,15 @@ static void ReadPaddleControl(const char* name, WORD& output)
}
}
+static void ReadHCV1000Control(const char* name, WORD& output)
+{
+ UINT temp;
+ temp = GetPrivateProfileInt("Slot2.HCV1000", name, -1, IniName);
+ if (temp != -1) {
+ output = temp;
+ }
+}
+
void LoadHotkeyConfig()
{
SCustomKey *key = &CustomKeys.key(0);
@@ -452,6 +464,15 @@ static void LoadPaddleConfig()
ReadPaddleControl("INC", Paddle.INC);
}
+static void LoadHCV1000Config()
+{
+ memcpy(&HCV1000, &DefaultHCV1000, sizeof(HCV1000));
+
+#define DO(X) ReadHCV1000Control(#X,HCV1000.X);
+ DO(SCANKEY);
+#undef DO
+}
+
static void LoadInputConfig()
{
@@ -2690,6 +2711,7 @@ void input_init()
LoadGuitarConfig();
LoadPianoConfig();
LoadPaddleConfig();
+ LoadHCV1000Config();
di_init();
FeedbackON = input_feedback;
@@ -2816,6 +2838,12 @@ void input_acquire()
if (inc) nds.paddle += 5;
if (dec) nds.paddle -= 5;
}
+
+ if (HCV1000.Enabled)
+ {
+ bool scan = !S9xGetState(HCV1000.SCANKEY);
+ if (scan) HCV1000_setReady();
+ }
}
else
{
diff --git a/desmume/src/frontend/windows/inputdx.h b/desmume/src/frontend/windows/inputdx.h
index 4ed3bd45a..5b23b2c3f 100644
--- a/desmume/src/frontend/windows/inputdx.h
+++ b/desmume/src/frontend/windows/inputdx.h
@@ -3,7 +3,7 @@
licensed under the terms supplied at the end of this file (for the terms are very long!)
Differences from that baseline version are:
- Copyright (C) 2008-2010 DeSmuME team
+ Copyright (C) 2008-2023 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -153,9 +153,15 @@ struct SPaddle {
WORD INC;
};
+struct SHCV1000 {
+ BOOL Enabled;
+ WORD SCANKEY;
+};
+
extern SGuitar Guitar;
extern SPiano Piano;
extern SPaddle Paddle;
+extern SHCV1000 HCV1000;
#endif
diff --git a/desmume/src/frontend/windows/main.cpp b/desmume/src/frontend/windows/main.cpp
index 292266afa..052c4f5cb 100644
--- a/desmume/src/frontend/windows/main.cpp
+++ b/desmume/src/frontend/windows/main.cpp
@@ -1,6 +1,6 @@
/*
Copyright (C) 2006 Theo Berkau
- Copyright (C) 2006-2019 DeSmuME team
+ Copyright (C) 2006-2023 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -1580,6 +1580,7 @@ static BOOL LoadROM(const char * filename, const char * physicalName, const char
Guitar.Enabled = (selectedSlot2Type == NDS_SLOT2_GUITARGRIP)?true:false;
Piano.Enabled = (selectedSlot2Type == NDS_SLOT2_EASYPIANO)?true:false;
Paddle.Enabled = (selectedSlot2Type == NDS_SLOT2_PADDLE)?true:false;
+ HCV1000.Enabled = (selectedSlot2Type == NDS_SLOT2_HCV1000)?true:false;
LoadSaveStateInfo();
lagframecounter=0;
@@ -2197,6 +2198,8 @@ int _main()
win32_CFlash_cfgDirectory = GetPrivateProfileStdString("Slot2.CFlash", "path", "");
win32_CFlash_cfgFileName = GetPrivateProfileStdString("Slot2.CFlash", "filename", "");
win32_GBA_cfgRomPath = GetPrivateProfileStdString("Slot2.GBAgame", "filename", "");
+ win32_HCV1000_barcode = GetPrivateProfileStdString("Slot2.HCV1000", "barcode", "");
+ memcpy(hcv1000_data, win32_HCV1000_barcode.c_str(), (win32_HCV1000_barcode.length() <= 16) ? win32_HCV1000_barcode.length() : 16);
cmdline.process_addonCommands();
WIN_InstallCFlash();
@@ -2258,6 +2261,8 @@ int _main()
break;
case NDS_SLOT2_PASSME:
break;
+ case NDS_SLOT2_HCV1000:
+ break;
default:
slot2_device_type = NDS_SLOT2_NONE;
break;
@@ -2268,6 +2273,7 @@ int _main()
Guitar.Enabled = (slot2_device_type == NDS_SLOT2_GUITARGRIP)?true:false;
Piano.Enabled = (slot2_device_type == NDS_SLOT2_EASYPIANO)?true:false;
Paddle.Enabled = (slot2_device_type == NDS_SLOT2_PADDLE)?true:false;
+ HCV1000.Enabled = (slot2_device_type == NDS_SLOT2_HCV1000)?true:false;
CommonSettings.WifiBridgeDeviceID = GetPrivateProfileInt("Wifi", "BridgeAdapter", 0, IniName);
diff --git a/desmume/src/frontend/windows/resource.h b/desmume/src/frontend/windows/resource.h
index a753958ae..8dd6224cc 100644
--- a/desmume/src/frontend/windows/resource.h
+++ b/desmume/src/frontend/windows/resource.h
@@ -514,7 +514,9 @@
#define IDC_WIFI_ENABLED 1065
#define IDC_STATIC_RANGE 1066
#define IDC_WIFI_COMPAT 1066
+#define IDC_HCVSCAN 1066
#define IDC_TEXSCALE 1067
+#define IDC_HCVBARCODE 1067
#define IDC_BADD 1068
#define IDC_LIST 1069
#define IDC_TEX_DEPOSTERIZE 1070
@@ -923,6 +925,7 @@
#define IDD_SLOT1_R4 10012
#define IDD_SLOT1_DEBUG 10013
#define IDD_GBASLOT_PADDLE 10014
+#define IDD_GBASLOT_HCV1000 10015
#define IDM_FILE_STOPAVI 40000
#define IDM_SCREENSEP_NONE 40000
#define IDM_FILE_STOPWAV 40001
@@ -1156,7 +1159,7 @@
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 128
#define _APS_NEXT_COMMAND_VALUE 40159
-#define _APS_NEXT_CONTROL_VALUE 1066
+#define _APS_NEXT_CONTROL_VALUE 1068
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/desmume/src/frontend/windows/resources.rc b/desmume/src/frontend/windows/resources.rc
index 2fe3bc9c6..e60a04fb7 100644
--- a/desmume/src/frontend/windows/resources.rc
+++ b/desmume/src/frontend/windows/resources.rc
@@ -1591,6 +1591,17 @@ BEGIN
RTEXT "Decrease",-1,81,40,44,8
END
+IDD_GBASLOT_HCV1000 DIALOGEX 7, 48, 302, 109
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE | WS_SYSMENU
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ EDITTEXT IDC_HCVBARCODE,129,42,72,14,ES_AUTOHSCROLL
+ CONTROL " ",IDC_HCVSCAN,"InputCustomGuitar",WS_TABSTOP,129,24,71,12,WS_EX_CLIENTEDGE
+ RTEXT "Scan key",-1,80,27,46,8
+ LTEXT "Card reader",-1,137,8,53,15
+ RTEXT "Barcode",-1,79,46,46,8
+END
+
/////////////////////////////////////////////////////////////////////////////
//
diff --git a/desmume/src/slot2.cpp b/desmume/src/slot2.cpp
index 4640b5a0b..a947fe7b6 100644
--- a/desmume/src/slot2.cpp
+++ b/desmume/src/slot2.cpp
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2009-2015 DeSmuME team
+ Copyright (C) 2009-2023 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -58,6 +58,7 @@ void slot2_Init()
extern TISlot2InterfaceConstructor construct_Slot2_EasyPiano;
extern TISlot2InterfaceConstructor construct_Slot2_Paddle;
extern TISlot2InterfaceConstructor construct_Slot2_PassME;
+ extern TISlot2InterfaceConstructor construct_Slot2_HCV1000;
slot2_List[NDS_SLOT2_NONE] = construct_Slot2_None();
slot2_List[NDS_SLOT2_AUTO] = construct_Slot2_Auto();
@@ -69,6 +70,7 @@ void slot2_Init()
slot2_List[NDS_SLOT2_EASYPIANO] = construct_Slot2_EasyPiano();
slot2_List[NDS_SLOT2_PADDLE] = construct_Slot2_Paddle();
slot2_List[NDS_SLOT2_PASSME] = construct_Slot2_PassME();
+ slot2_List[NDS_SLOT2_HCV1000] = construct_Slot2_HCV1000();
}
@@ -252,6 +254,9 @@ NDS_SLOT2_TYPE slot2_DetermineTypeByGameCode(const char *theGameCode)
{"CV8", NDS_SLOT2_PADDLE}, // Space Invaders Extreme 2
{"AMH", NDS_SLOT2_RUMBLEPAK}, // Metroid Prime Hunters
{"AP2", NDS_SLOT2_RUMBLEPAK}, // Metroid Prime Pinball
+ {"C4A", NDS_SLOT2_HCV1000}, // Card de Asobu! Hajimete no DS
+ {"A6I", NDS_SLOT2_HCV1000}, // Kouchuu Ouja: Mushi King Super Collection
+ {"ALB", NDS_SLOT2_HCV1000}, // Oshare Majo Berry and Love
};
for(size_t i = 0; i < ARRAY_SIZE(gameCodeDeviceTypes); i++)
diff --git a/desmume/src/slot2.h b/desmume/src/slot2.h
index dd015fe23..a50631629 100644
--- a/desmume/src/slot2.h
+++ b/desmume/src/slot2.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2009-2015 DeSmuME team
+ Copyright (C) 2009-2023 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -97,6 +97,7 @@ enum NDS_SLOT2_TYPE
NDS_SLOT2_EASYPIANO, // 0x06 - Easy Piano
NDS_SLOT2_PADDLE, // 0x07 - Arkanoids DS paddle
NDS_SLOT2_PASSME, // 0x08 - PassME/Homebrew
+ NDS_SLOT2_HCV1000, // 0x09 - HCV-1000 Sega Card Reader
NDS_SLOT2_COUNT // use for counter addons - MUST TO BE LAST!!!
};
@@ -142,6 +143,7 @@ bool slot2_read(u32 addr, T &val);
extern std::string GBACartridge_RomPath;
extern std::string GBACartridge_SRAMPath;
extern void (*FeedbackON)(bool enable); // feedback on/off
+extern char hcv1000_data[16];
enum ADDON_CFLASH_MODE
{
@@ -157,4 +159,5 @@ void Paddle_SetValue(u16 theValue);
extern void guitarGrip_setKey(bool green, bool red, bool yellow, bool blue); // Guitar grip keys
extern void piano_setKey(bool c, bool cs, bool d, bool ds, bool e, bool f, bool fs, bool g, bool gs, bool a, bool as, bool b, bool hic); //piano keys
+extern void HCV1000_setReady();
#endif //__SLOT_H__