From 659488ce2debb840ecc04d7c0f94fb5fd05a4662 Mon Sep 17 00:00:00 2001 From: Daniel Stuart Baxter Date: Tue, 27 Aug 2024 21:35:15 -0500 Subject: [PATCH] [DMG] Add IR Noise option. Useful for fusions in the SMT Devil Children games. --- src/common/config.cpp | 2 +- src/dmg/mmu.cpp | 9 +++++++++ src/dmg/sio.cpp | 5 +++++ src/dmg/sio_data.h | 1 + src/gbe.ini | 2 +- 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/common/config.cpp b/src/common/config.cpp index dde4257d..28694de6 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -1207,7 +1207,7 @@ bool parse_ini_file() if(!parse_ini_number(ini_item, "#sio_device", config::sio_device, ini_opts, x, 0, 20)) { return false; } //Emulated IR device - if(!parse_ini_number(ini_item, "#ir_device", config::ir_device, ini_opts, x, 0, 7)) { return false; } + if(!parse_ini_number(ini_item, "#ir_device", config::ir_device, ini_opts, x, 0, 8)) { return false; } //Emulated Slot1 device if(!parse_ini_number(ini_item, "#slot1_device", config::nds_slot1_device, ini_opts, x, 0, 1)) { return false; } diff --git a/src/dmg/mmu.cpp b/src/dmg/mmu.cpp index 3f654341..cd87a1ec 100644 --- a/src/dmg/mmu.cpp +++ b/src/dmg/mmu.cpp @@ -385,6 +385,15 @@ u8 DMG_MMU::read_u8(u16 address) sio_stat->shifts_left = 1; } + //Change IR light status randomly for IR Noise option + if(sio_stat->ir_type == GBC_IR_NOISE) + { + u8 noise = (rand() & 0x1); + + if(noise) { memory_map[address] &= ~0x2; } + else { memory_map[address] |= 0x2; } + } + //If Bits 6 and 7 are not set, treat Bit 1 as HIGH if((memory_map[address] & 0xC0) == 0) { return memory_map[address] | 0x2; } diff --git a/src/dmg/sio.cpp b/src/dmg/sio.cpp index 7adb9942..13d4f25f 100644 --- a/src/dmg/sio.cpp +++ b/src/dmg/sio.cpp @@ -345,6 +345,11 @@ void DMG_SIO::reset() sio_stat.ir_type = GBC_LIGHT_SOURCE; break; + //IR Noise + case 8: + sio_stat.ir_type = GBC_IR_NOISE; + break; + //Use standard GBC IR port communication as the default (GBE+ will ignore it for DMG games) //Also, any invalid types are ignored default: diff --git a/src/dmg/sio_data.h b/src/dmg/sio_data.h index 6284308a..8956572e 100644 --- a/src/dmg/sio_data.h +++ b/src/dmg/sio_data.h @@ -38,6 +38,7 @@ enum ir_types GBC_POCKET_SAKURA, GBC_TV_REMOTE, GBC_LIGHT_SOURCE, + GBC_IR_NOISE, }; enum printer_state diff --git a/src/gbe.ini b/src/gbe.ini index fc1fcda2..57966d46 100644 --- a/src/gbe.ini +++ b/src/gbe.ini @@ -17,7 +17,7 @@ //Emulated infrared device //0 - GBC IR port (or nothing for DMG games), 1 - Full Changer (Zok Zok Heroes), 2 - Pokemon Pikachu 2 //3 - Pocket Sakura, 4 - TV Remote, 5 - Constant Light Source (Chee Chai Alien) -//6 - Zoids CDZ Model, 7 - NTR-027 Activity Meter +//6 - Zoids CDZ Model, 7 - NTR-027 Activity Meter, 8 - IR Noise [#ir_device:0] //Emulated NDS Slot1 device