Skip to content

Commit

Permalink
Merge pull request #735 from windwakr/hcv1000-fixes
Browse files Browse the repository at this point in the history
Slot2: Sega Card Reader fixes
  • Loading branch information
zeromus authored Oct 7, 2023
2 parents f3dee5d + 8be30fe commit 0b027d8
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
6 changes: 6 additions & 0 deletions desmume/src/addons/slot2_hcv1000.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,9 @@ void HCV1000_setReady()
{
hcv1000_cnt &= ~0x80;
}

void HCV1000_setBarcode(std::string barcode)
{
barcode.resize(16, '_');
memcpy(hcv1000_data, barcode.c_str(), barcode.length());
}
14 changes: 7 additions & 7 deletions desmume/src/frontend/windows/gbaslot_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ 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 };
char tmp_hcv1000_barcode[17] = { 0 };
ADDON_CFLASH_MODE tmp_CFlashMode = ADDON_CFLASH_MODE_RomPath;
HWND OKbutton = NULL;
bool _OKbutton = false;
Expand All @@ -50,7 +50,8 @@ SHCV1000 tmp_HCV1000;
std::string win32_CFlash_cfgDirectory, win32_CFlash_cfgFileName;
UINT win32_CFlash_cfgMode;
std::string win32_GBA_cfgRomPath;
std::string win32_HCV1000_barcode;

std::string slot2_HCV1000_barcode;

INT_PTR CALLBACK GbaSlotNone(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam)
{
Expand Down Expand Up @@ -305,7 +306,7 @@ INT_PTR CALLBACK GbaSlotHCV1000(HWND dialog, UINT msg, WPARAM wparam, LPARAM lpa
switch (LOWORD(wparam))
{
case IDC_HCVBARCODE:
GetWindowText(GetDlgItem(dialog, IDC_HCVBARCODE), tmp_hcv1000_barcode, 16);
GetWindowText(GetDlgItem(dialog, IDC_HCVBARCODE), tmp_hcv1000_barcode, 17);

return FALSE;
}
Expand Down Expand Up @@ -619,7 +620,7 @@ 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());
strcpy(tmp_hcv1000_barcode, slot2_HCV1000_barcode.c_str());
memcpy(&tmp_Guitar, &Guitar, sizeof(Guitar));
memcpy(&tmp_Piano, &Piano, sizeof(Piano));
memcpy(&tmp_Paddle, &Paddle, sizeof(Paddle));
Expand Down Expand Up @@ -689,10 +690,9 @@ void GBAslotDialog(HWND hwnd)
case NDS_SLOT2_PASSME:
break;
case NDS_SLOT2_HCV1000:
win32_HCV1000_barcode = tmp_hcv1000_barcode;
slot2_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);
HCV1000_setBarcode(slot2_HCV1000_barcode);
WritePrivateProfileString("Slot2.HCV1000", "barcode", tmp_hcv1000_barcode, IniName);
WritePrivateProfileInt("Slot2.HCV1000", "scankey", HCV1000.SCANKEY, IniName);
break;
Expand Down
3 changes: 2 additions & 1 deletion desmume/src/frontend/windows/gbaslot_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
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 std::string slot2_HCV1000_barcode;

extern void GBAslotDialog(HWND hwnd);

Expand Down
5 changes: 3 additions & 2 deletions desmume/src/frontend/windows/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2198,8 +2198,9 @@ 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);

slot2_HCV1000_barcode = GetPrivateProfileStdString("Slot2.HCV1000", "barcode", "").substr(0, 16);
HCV1000_setBarcode(slot2_HCV1000_barcode);

cmdline.process_addonCommands();
WIN_InstallCFlash();
Expand Down
2 changes: 1 addition & 1 deletion desmume/src/slot2.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ 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
{
Expand All @@ -160,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();
extern void HCV1000_setBarcode(std::string barcode);
#endif //__SLOT_H__

3 comments on commit 0b027d8

@halpz
Copy link

@halpz halpz commented on 0b027d8 Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR breaks the macOS build. I get the error:

ld: warning: -no_pie ignored for arm64*
ld: Undefined symbols:
construct_Slot2_HCV1000(), referenced from:
-[CocoaDSCore init] in lto.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@windwakr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was the previous PR that broke the Mac build. The new slot2_hcv1000.cpp file needs to be added to the Mac project file.

@rogerman
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Mac build (Cocoa port) is fixed in commit b06537c. However, this particular commit does not add the actual support for the barcode reader. New UI has to made for that. Therefore, barcode reader support on Mac will have to come in a future update.

Please sign in to comment.