├── README.md ├── common └── x86 │ ├── x86_mem.cpp │ └── x86_mem.hpp ├── emitter ├── emitter.vcxproj ├── generated_class_names.h ├── generated_class_names_string.h ├── generated_descriptors.h ├── generated_indexes.h ├── types.h ├── x86_emitter.cpp ├── x86_emitter.h ├── x86_matcher.h ├── x86_op_classes.h ├── x86_op_encoder.h └── x86_op_table.h └── nulldc ├── WorkDir ├── Plugins │ └── pfctoc.dll ├── SDL.dll ├── data │ ├── Put dc_boot here.txt │ ├── fsca-table.bin │ └── vmu_default.bin ├── ps_hlsl.fx └── vs_hlsl.fx ├── compiling-advanced.txt ├── compiling.txt ├── nullDC.sln ├── nullDC ├── algo │ └── algo.hpp ├── basic_types.h ├── cl │ ├── cl.cpp │ └── cl.h ├── config │ ├── config.cpp │ └── config.h ├── dc │ ├── aica │ │ ├── aica_if.cpp │ │ └── aica_if.h │ ├── asic │ │ ├── asic.cpp │ │ └── asic.h │ ├── dc.cpp │ ├── dc.h │ ├── gdrom │ │ ├── gdrom_if.h │ │ ├── gdrom_response.cpp │ │ ├── gdromv3.cpp │ │ └── gdromv3.h │ ├── maple │ │ ├── maple_if.cpp │ │ └── maple_if.h │ ├── mem │ │ ├── Elf.cpp │ │ ├── Elf.h │ │ ├── _vmem.cpp │ │ ├── _vmem.h │ │ ├── memutil.cpp │ │ ├── memutil.h │ │ ├── mmu.cpp │ │ ├── mmu.h │ │ ├── sb.cpp │ │ ├── sb.h │ │ ├── sh4_area0.cpp │ │ ├── sh4_area0.h │ │ ├── sh4_internal_reg.cpp │ │ ├── sh4_internal_reg.h │ │ ├── sh4_mem.cpp │ │ └── sh4_mem.h │ ├── pvr │ │ ├── pvrLock.cpp │ │ ├── pvrLock.h │ │ ├── pvr_if.cpp │ │ ├── pvr_if.h │ │ ├── pvr_sb_regs.cpp │ │ └── pvr_sb_regs.h │ └── sh4 │ │ ├── bsc.cpp │ │ ├── bsc.h │ │ ├── ccn.cpp │ │ ├── ccn.h │ │ ├── cpg.cpp │ │ ├── cpg.h │ │ ├── dmac.cpp │ │ ├── dmac.h │ │ ├── intc.cpp │ │ ├── intc.h │ │ ├── intc_types.h │ │ ├── rec_v1 │ │ ├── analyser.cpp │ │ ├── analyser.h │ │ ├── basicblock.cpp │ │ ├── basicblock.h │ │ ├── blockmanager.cpp │ │ ├── blockmanager.h │ │ ├── codespan.cpp │ │ ├── codespan.h │ │ ├── compiledblock.cpp │ │ ├── compiledblock.h │ │ ├── driver.cpp │ │ ├── driver.h │ │ ├── ops.h │ │ ├── recompiler.h │ │ ├── sh4_cpu_shil.cpp │ │ ├── sh4_cpu_shil.h │ │ ├── sh4_fpu_shil.cpp │ │ └── sh4_fpu_shil.h │ │ ├── rtc.cpp │ │ ├── rtc.h │ │ ├── sci.cpp │ │ ├── sci.h │ │ ├── scif.cpp │ │ ├── scif.h │ │ ├── sh4_cpu.cpp │ │ ├── sh4_cpu.h │ │ ├── sh4_cpu_arith.h │ │ ├── sh4_cpu_branch.h │ │ ├── sh4_cpu_branch_rec.h │ │ ├── sh4_cpu_loadstore.h │ │ ├── sh4_cpu_logic.h │ │ ├── sh4_cpu_movs.h │ │ ├── sh4_fpu.cpp │ │ ├── sh4_fpu.h │ │ ├── sh4_if.cpp │ │ ├── sh4_if.h │ │ ├── sh4_interpreter.cpp │ │ ├── sh4_interpreter.h │ │ ├── sh4_opcode_list.cpp │ │ ├── sh4_opcode_list.h │ │ ├── sh4_registers.cpp │ │ ├── sh4_registers.h │ │ ├── shil │ │ ├── compiler │ │ │ ├── shil_compiler_base.cpp │ │ │ └── shil_compiler_base.h │ │ ├── shil.cpp │ │ ├── shil.h │ │ ├── shil_ce.cpp │ │ └── shil_ce.h │ │ ├── tmu.cpp │ │ ├── tmu.h │ │ ├── ubc.cpp │ │ └── ubc.h ├── debug_mem.cpp ├── emitter │ ├── BaseTypes.h │ ├── emitter.cpp │ ├── emitter.h │ └── regalloc │ │ ├── regalloc.h │ │ ├── regalloc_base.h │ │ ├── x86_intregalloc.cpp │ │ ├── x86_intregalloc.h │ │ ├── x86_sseregalloc.cpp │ │ └── x86_sseregalloc.h ├── gui │ ├── base.cpp │ ├── base.h │ ├── ndc_icon.ico │ ├── resource.h │ └── resource.rc ├── log │ ├── logging.cpp │ ├── logging.h │ └── logging_interface.h ├── naomi │ ├── naomi.cpp │ ├── naomi.h │ └── naomi_regs.h ├── nullDC.cpp ├── nullDC.vcxproj ├── nullDC.vcxproj.filters ├── plugins │ ├── gui_plugin_header.h │ ├── plugin_header.h │ ├── plugin_manager.cpp │ ├── plugin_manager.h │ ├── plugin_types.cpp │ └── plugin_types.h ├── profiler │ ├── profiler.cpp │ └── profiler.h ├── serial_ipc │ ├── serial_ipc_client.cpp │ └── serial_ipc_client.h ├── sh4_reg_playground.h ├── stdclass.cpp ├── stdclass.h ├── timing │ └── timer.hpp └── types.h ├── plugins ├── EmptyAICA │ ├── EmptyAICA.cpp │ ├── EmptyAICA.h │ ├── EmptyAICA.vcxproj │ ├── EmptyAICA.vcxproj.filters │ ├── aica_hax.cpp │ ├── aica_hax.h │ ├── aica_hle.cpp │ ├── aica_hle.h │ └── exports.def ├── ImgReader │ ├── ImgReader.cpp │ ├── ImgReader.h │ ├── ImgReader.vcxproj │ ├── ImgReader.vcxproj.filters │ ├── SCSIDEFS.H │ ├── UI.rc │ ├── cdi.cpp │ ├── cdi.h │ ├── chd.cpp │ ├── chd.h │ ├── common.cpp │ ├── common.h │ ├── deps │ │ ├── chd.h │ │ ├── chdr.cpp │ │ ├── coretypes.h │ │ ├── md5.cpp │ │ ├── md5.h │ │ ├── sha1.cpp │ │ ├── sha1.h │ │ └── zlib │ │ │ ├── adler32.c │ │ │ ├── compress.c │ │ │ ├── crc32.c │ │ │ ├── crc32.h │ │ │ ├── deflate.c │ │ │ ├── deflate.h │ │ │ ├── example.c │ │ │ ├── gzio.c │ │ │ ├── infback.c │ │ │ ├── inffast.c │ │ │ ├── inffast.h │ │ │ ├── inffixed.h │ │ │ ├── inflate.c │ │ │ ├── inflate.h │ │ │ ├── inftrees.c │ │ │ ├── inftrees.h │ │ │ ├── trees.c │ │ │ ├── trees.h │ │ │ ├── uncompr.c │ │ │ ├── zconf.h │ │ │ ├── zconf.in.h │ │ │ ├── zlib.h │ │ │ ├── zutil.c │ │ │ └── zutil.h │ ├── exports.def │ ├── gd_driver.h │ ├── gdi.cpp │ ├── gdi.h │ ├── ioctl.cpp │ ├── ioctl.h │ ├── mds.cpp │ ├── mds.h │ ├── mds_reader.cpp │ ├── mds_reader.h │ ├── pfctoc.h │ ├── pfctoc.lib │ ├── resource.h │ ├── ui.cpp │ └── ui.h ├── PuruPuru │ ├── Devices.h │ ├── Dreamcast_Controller.cpp │ ├── InputStuff.cpp │ ├── NAOMI JAMMA.cpp │ ├── PuruPuru.cpp │ ├── PuruPuru.h │ ├── PuruPuru.rc │ ├── PuruPuru.vcxproj │ ├── PuruPuru.vcxproj.filters │ ├── PuruPuru_Pakku.cpp │ ├── config.cpp │ ├── config.h │ ├── exports.def │ ├── images │ │ ├── ICON_OFF.bmp │ │ ├── ICON_ON.bmp │ │ ├── ICON_ON2.bmp │ │ ├── Naomi.bmp │ │ ├── full_dreamcast_controller.bmp │ │ └── purupurulogo.bmp │ └── resource.h ├── XMaple │ ├── ArcadeStick.cpp │ ├── ArcadeStick.h │ ├── DInputBackend.cpp │ ├── DInputBackend.h │ ├── Device.cpp │ ├── Device.hpp │ ├── DreameyeMic.cpp │ ├── DreameyeMic.h │ ├── FT0.cpp │ ├── FT0.h │ ├── FT4.cpp │ ├── FT4.h │ ├── FT8.cpp │ ├── FT8.h │ ├── MapleInterface.h │ ├── Maxi.cpp │ ├── Maxi.h │ ├── Mic.cpp │ ├── Mic.h │ ├── StandardController.cpp │ ├── StandardController.h │ ├── Twinstick.cpp │ ├── Twinstick.h │ ├── VIBRATIONFUNCTION.cpp │ ├── XInputBackend.cpp │ ├── XInputBackend.h │ ├── XMaple.cpp │ ├── XMaple.h │ ├── XMaple.vcxproj │ ├── XMaple.vcxproj.filters │ ├── exports.def │ └── readme.txt ├── drkMapleDevices │ ├── drkMapleDevices.cpp │ ├── drkMapleDevices.rc │ ├── drkMapleDevices.vcxproj │ ├── drkMapleDevices.vcxproj.filters │ ├── exports.def │ └── resource.h ├── drkPvr │ ├── Renderer_if.cpp │ ├── Renderer_if.h │ ├── SPG.cpp │ ├── TexCache.cpp │ ├── TexCache.h │ ├── composition.fx │ ├── config.h │ ├── d3d11.fx │ ├── d3dRend.cpp │ ├── d3dRend.h │ ├── d3dRend11.cpp │ ├── d3dRend11.h │ ├── drkPvr.cpp │ ├── drkPvr.h │ ├── drkPvr.vcxproj │ ├── drkPvr.vcxproj.filters │ ├── exports.def │ ├── helper_classes.cpp │ ├── helper_classes.h │ ├── nullRend.cpp │ ├── nullRend.h │ ├── ps_hlsl.fx │ ├── pvr_algo │ │ ├── pvr_algo.hpp │ │ └── pvr_r.hpp │ ├── regs.cpp │ ├── regs.h │ ├── spg.h │ ├── ta.cpp │ ├── ta.h │ ├── ta_const_df.h │ ├── ta_structs.h │ └── vs_hlsl.fx ├── gpARM │ ├── aica.cpp │ ├── aica.h │ ├── cpu.c │ ├── cpu.h │ ├── exports.def │ ├── gpARM.cpp │ ├── gpARM.vcxproj │ └── x86 │ │ ├── Makefile │ │ ├── x86_emit.h │ │ └── x86_stub.S ├── mudPvr │ ├── exports.def │ ├── mudpvr.sln │ ├── mudpvr.suo │ ├── mudpvr.vcxproj │ └── src │ │ ├── TexCache.cpp │ │ ├── TexCache.h │ │ ├── helper_classes.cpp │ │ ├── helper_classes.h │ │ ├── mudpvr.cpp │ │ ├── mudpvr.h │ │ ├── pvr_impl.cpp │ │ ├── pvr_impl.h │ │ ├── pvr_renderer_d3d1x.cpp │ │ ├── pvr_renderer_d3d1x.h │ │ ├── regs.h │ │ ├── ta.cpp │ │ ├── ta.h │ │ ├── ta_const_df.h │ │ └── ta_structs.h ├── nullAICA │ ├── ReadMe.txt │ ├── aica.cpp │ ├── aica.h │ ├── audiostream.cpp │ ├── audiostream.h │ ├── audiostream_rif.h │ ├── config_ui.cpp │ ├── config_ui.h │ ├── debugger_ui.cpp │ ├── debugger_ui.h │ ├── ds_audiostream.cpp │ ├── ds_audiostream.h │ ├── dsp.cpp │ ├── dsp.h │ ├── exports.def │ ├── gui.h │ ├── mem.cpp │ ├── mem.h │ ├── nullAICA.cpp │ ├── nullAICA.h │ ├── nullAICA.rc │ ├── nullAICA.vcxproj │ ├── nullAICA.vcxproj.filters │ ├── resource.h │ ├── sdl_audiostream.cpp │ ├── sdl_audiostream.h │ ├── sgc_if.cpp │ └── sgc_if.h ├── nullDC_GUI │ ├── CPicture.cpp │ ├── CPicture.h │ ├── CtrlDisAsmView.cpp │ ├── CtrlDisAsmView.h │ ├── CtrlMemView.cpp │ ├── CtrlMemView.h │ ├── DebugInterface.h │ ├── SH4DbgInterface.cpp │ ├── SH4DbgInterface.h │ ├── Script1.rc │ ├── Symbols.h │ ├── emuWinUI.cpp │ ├── emuWinUI.h │ ├── export.def │ ├── hwbrk.cpp │ ├── hwbrk.h │ ├── icon2.ico │ ├── icon3.ico │ ├── ndc_icon.ico │ ├── nullDC_GUI.cpp │ ├── nullDC_GUI.h │ ├── nullDC_GUI.vcxproj │ ├── nullDC_GUI.vcxproj.filters │ ├── nulldc640_bluebg-opt96.jpeg │ ├── resource.h │ ├── screenshot.cpp │ └── screenshot.h ├── nullExtDev │ ├── bba.cpp │ ├── bba.h │ ├── exports.def │ ├── lan.cpp │ ├── lan.h │ ├── modem.cpp │ ├── modem.h │ ├── nullExtDev.cpp │ ├── nullExtDev.h │ ├── nullExtDev.vcxproj │ ├── nullExtDev.vcxproj.filters │ ├── pcap_io.cpp │ ├── pcap_io.h │ ├── rtl8139c.cpp │ └── rtl8139c.h └── vbaARM │ ├── aica.cpp │ ├── aica.h │ ├── arm-new.h │ ├── arm7.cpp │ ├── arm7.h │ ├── exports.def │ ├── mem.cpp │ ├── mem.h │ ├── resource.h │ ├── vbaARM.cpp │ ├── vbaARM.h │ ├── vbaARM.vcxproj │ └── vbaARM.vcxproj.filters └── running.txt /README.md: -------------------------------------------------------------------------------- 1 | # nulldc 2 | nullDC, a sega dreamcast emulator for win86. 3 | 4 | I moved on to work on my new pet project, reicast, and while nullDC is still a 5 | better choice for dreamcast emulation on windows/x86 reicast is where the fun is. 6 | 7 | This is here for archival & reference. 8 | -------------------------------------------------------------------------------- /common/x86/x86_mem.hpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | Copyright (C) 2010-2013 Dimitris V. DimitrisV22@gmail.com 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 6 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the 8 | Software is furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 11 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 13 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE 14 | AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 15 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 17 | */ 18 | #ifndef _x86_mem 19 | #define _x86_mem 20 | void sse_memcpy_div22(void* dst,const void* src,unsigned int sz) ; 21 | #endif 22 | -------------------------------------------------------------------------------- /emitter/types.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //basic types 4 | typedef signed __int8 s8; 5 | typedef signed __int16 s16; 6 | typedef signed __int32 s32; 7 | typedef signed __int64 s64; 8 | 9 | typedef unsigned __int8 u8; 10 | typedef unsigned __int16 u16; 11 | typedef unsigned __int32 u32; 12 | typedef unsigned __int64 u64; 13 | 14 | typedef float f32; 15 | typedef double f64; 16 | 17 | #ifdef X86 18 | typedef u32 unat; 19 | #endif 20 | 21 | #ifdef X64 22 | typedef u64 unat; 23 | #endif 24 | 25 | 26 | //Do not complain when i use enum::member 27 | #pragma warning( disable : 4482) 28 | 29 | //unnamed struncts/unions 30 | #pragma warning( disable : 4201) 31 | 32 | //unused parameters 33 | #pragma warning( disable : 4100) 34 | 35 | //basic includes from runtime lib 36 | #include 37 | #include 38 | 39 | #include 40 | using namespace std; 41 | 42 | #ifndef dbgbreak 43 | #define dbgbreak __asm {int 3} 44 | #endif 45 | 46 | #ifndef verify 47 | #define verify(x) if((x)==false){ printf("Verify Failed : " #x "\n in %s -> %s : %d \n",__FUNCTION__,__FILE__,__LINE__); dbgbreak;} 48 | #endif 49 | 50 | #ifndef die 51 | #define die(reason) { printf("Fatal error : %s\n in %s -> %s : %d \n",reason,__FUNCTION__,__FILE__,__LINE__); dbgbreak;} 52 | #endif -------------------------------------------------------------------------------- /emitter/x86_op_classes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //auto generated 4 | enum x86_opcode_class 5 | { 6 | #include "generated_class_names.h" 7 | 8 | //////// 9 | op_count, 10 | }; -------------------------------------------------------------------------------- /emitter/x86_op_table.h: -------------------------------------------------------------------------------- 1 | 2 | //auto generated 3 | //Opcode data lists :) 4 | 5 | #define MA_1(x) {x} 6 | #define MA_2(x,y) {x,y} 7 | #define MA_3(x,y,z) {x,y,z} 8 | #define MA_4(x,y,z,l) {x,y,z,l} 9 | 10 | const x86_opcode all_opcodes[] = 11 | { 12 | #include "generated_descriptors.h" 13 | }; 14 | 15 | const x86_opcode* x86_opcode_list[op_count+1]= 16 | { 17 | #include "generated_indexes.h" 18 | }; 19 | -------------------------------------------------------------------------------- /nulldc/WorkDir/Plugins/pfctoc.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skmp/nullDC-v1/1611c3cf0aa2755611455aa7a02b4f62babee7bd/nulldc/WorkDir/Plugins/pfctoc.dll -------------------------------------------------------------------------------- /nulldc/WorkDir/SDL.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skmp/nullDC-v1/1611c3cf0aa2755611455aa7a02b4f62babee7bd/nulldc/WorkDir/SDL.dll -------------------------------------------------------------------------------- /nulldc/WorkDir/data/Put dc_boot here.txt: -------------------------------------------------------------------------------- 1 | put dc_boot.bin and dc_flash.bin in this directory -------------------------------------------------------------------------------- /nulldc/WorkDir/data/fsca-table.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skmp/nullDC-v1/1611c3cf0aa2755611455aa7a02b4f62babee7bd/nulldc/WorkDir/data/fsca-table.bin -------------------------------------------------------------------------------- /nulldc/WorkDir/data/vmu_default.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skmp/nullDC-v1/1611c3cf0aa2755611455aa7a02b4f62babee7bd/nulldc/WorkDir/data/vmu_default.bin -------------------------------------------------------------------------------- /nulldc/compiling-advanced.txt: -------------------------------------------------------------------------------- 1 | How to compile the optimized build(DC & Naomi): 2 | 3 | Look for : "#undef NO_VERIFY" (in nullDC/types.h) and replace it with : 4 | "#define NO_VERIFY" 5 | 6 | Look for : "#define DEFAULT_LOGGING" (in nullDC/log/logging_interface.h) and replace it with : 7 | "#undef DEFAULT_LOGGING" 8 | 9 | Set build settings to "Release-NoTrace" , save everything and compile. 10 | 11 | If you do the above , you'll notice a big difference in the block compile times 12 | and the overall performance of 13 | the emulator. 14 | 15 | How to compile with unknown bios reg writes auto-mapped(DC): 16 | Open nullDC/types.h. 17 | Replace "#undef SB_MAP_UNKNOWN_REGS" with "#define SB_MAP_UNKNOWN_REGS" and re-compile the solution. 18 | 19 | How to compile with dev tools active: 20 | Open nullDC/types.h 21 | Replace "#undef INCLUDE_DEV_TOOLS" with "#define INCLUDE_DEV_TOOLS" 22 | 23 | Macros associated with dev-tools: 24 | Just scan the entire solution for : "DEV_TOOL" and you'll get all related 25 | macros/patches ;) -------------------------------------------------------------------------------- /nulldc/compiling.txt: -------------------------------------------------------------------------------- 1 | In case you want to build the emu, here is some info to make your lives easier: 2 | 3 | You're gonna need Visual Studio .NET 2010 (NOT the express version!) to build the project. Express version might also work but it might do weird stuff and you'll need a Windows SDK, so I would not recommend it if you're not sure what you're doing. 4 | 5 | A recent version of the DirectX 9.0c SDK is also required to build most stuff. 6 | 7 | nullAICA uses optional sound streaming through the SDL development library so you'll need it to build with SDL support. SDL support will also have to be defined in the nullAICA source code. 8 | Note: Sound streaming through SDL is probably broken anyway. 9 | 10 | If you want to build the emulator with MMU support you have to define MMU support. This should be placed in "types.h" (last time I checked, it was already there but commented out). 11 | 12 | If you want to build a NAOMI, ATOMISWAVE, etc. version you should define which version you want in "plugin_types.h". The default definition is DC_PLATFORM_NORMAL (the definition is placed after the list with the available versions). 13 | 14 | drkMapleDevices comes with optional support for the LCD screen of some Logitech keyboards (G15). You've got to to define LCD support in "drkMapleDevices.cpp" for it to work. The LCD SDK is also needed to build the plugin that way. 15 | 16 | The LCD SDK version originally used is 1.04.153 17 | 18 | Last time I checked, nullExtDev needed the WinPcap library to build. 19 | 20 | EOF -------------------------------------------------------------------------------- /nulldc/nullDC/basic_types.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //basic types 4 | typedef signed __int8 s8; 5 | typedef signed __int16 s16; 6 | typedef signed __int32 s32; 7 | typedef signed __int64 s64; 8 | 9 | typedef unsigned __int8 u8; 10 | typedef unsigned __int16 u16; 11 | typedef unsigned __int32 u32; 12 | typedef unsigned __int64 u64; 13 | 14 | typedef float f32; 15 | typedef double f64; 16 | 17 | #ifdef X86 18 | typedef u32 unat; 19 | #endif 20 | 21 | #ifdef X64 22 | typedef u64 unat; 23 | #endif 24 | 25 | typedef wchar_t wchar; -------------------------------------------------------------------------------- /nulldc/nullDC/cl/cl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | bool ParseCommandLine(int argc,wchar* argv[]); -------------------------------------------------------------------------------- /nulldc/nullDC/config/config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types.h" 4 | 5 | /* 6 | ** cfg* prototypes, if you pass NULL to a cfgSave* it will wipe out the section 7 | ** } if you pass it to lpKey it will wipe out that particular entry 8 | ** } if you add write to something it will create it if its not present 9 | ** } ** Strings passed to LoadStr should be MAX_PATH in size ! ** 10 | */ 11 | 12 | extern wchar cfgPath[512]; 13 | bool cfgOpen(); 14 | s32 EXPORT_CALL cfgLoadInt(const wchar * lpSection, const wchar * lpKey,s32 Default); 15 | void EXPORT_CALL cfgSaveInt(const wchar * lpSection, const wchar * lpKey, s32 Int); 16 | void EXPORT_CALL cfgLoadStr(const wchar * lpSection, const wchar * lpKey, wchar * lpReturn,const wchar* lpDefault); 17 | void EXPORT_CALL cfgSaveStr(const wchar * lpSection, const wchar * lpKey, const wchar * lpString); 18 | s32 EXPORT_CALL cfgExists(const wchar * Section, const wchar * Key); 19 | void cfgSetVitual(const wchar * lpSection, const wchar * lpKey, const wchar * lpString); 20 | 21 | -------------------------------------------------------------------------------- /nulldc/nullDC/dc/aica/aica_if.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "types.h" 3 | 4 | extern u32 VREG; 5 | extern VArray2 aica_ram; 6 | u32 ReadMem_aica_rtc(u32 addr,u32 sz); 7 | void WriteMem_aica_rtc(u32 addr,u32 data,u32 sz); 8 | u32 FASTCALL ReadMem_aica_reg(u32 addr,u32 sz); 9 | void FASTCALL WriteMem_aica_reg(u32 addr,u32 data,u32 sz); 10 | 11 | void aica_Init(); 12 | void aica_Reset(bool Manual); 13 | void aica_Term(); 14 | 15 | #define UpdateAica(clc) libAICA.Update(clc) 16 | #define UpdateArm(clc) libARM.Update(clc) 17 | 18 | void aica_sb_Init(); 19 | void aica_sb_Reset(bool Manual); 20 | void aica_sb_Term(); -------------------------------------------------------------------------------- /nulldc/nullDC/dc/asic/asic.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "types.h" 3 | #include "dc\sh4\intc.h" 4 | 5 | 6 | void fastcall asic_RaiseInterrupt(HollyInterruptID inter); 7 | void fastcall asic_CancelInterrupt(HollyInterruptID inter); 8 | 9 | //Init/Res/Term for regs 10 | void asic_reg_Init(); 11 | void asic_reg_Term(); 12 | void asic_reg_Reset(bool Manual); -------------------------------------------------------------------------------- /nulldc/nullDC/dc/dc.h: -------------------------------------------------------------------------------- 1 | //dc.h 2 | //header for dc.cpp 3 | #pragma once 4 | #include "types.h" 5 | #include "mem/sh4_mem.h" 6 | #include "mem/memutil.h" 7 | #include "sh4/sh4_if.h" 8 | 9 | bool Init_DC(); 10 | //this is to be called from emulation code 11 | bool SoftReset_DC(); 12 | //this is to be called from external thread 13 | bool Reset_DC(bool Manual); 14 | void Term_DC(); 15 | void Start_DC(); 16 | void Stop_DC(); 17 | bool IsDCInited(); 18 | void SwitchCPU_DC(); 19 | 20 | extern void* hEmuThread; -------------------------------------------------------------------------------- /nulldc/nullDC/dc/gdrom/gdrom_if.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** gdrom_if.h 3 | */ 4 | #ifndef __GDROM_IF_H__ 5 | #define __GDROM_IF_H__ 6 | 7 | #include "types.h" 8 | #include "plugins/plugin_manager.h" 9 | 10 | //there were at least 4 gdrom implementations, ZGDROM, HLE, gdromv1 (never worked), gdromv2 (first release) 11 | //i removed the #defines to select them as they are now redutant, so this just becomes a part of 12 | //the code's history :) 13 | #include "gdromv3.h" 14 | 15 | void gdrom_reg_Init(void); 16 | void gdrom_reg_Term(void); 17 | void gdrom_reg_Reset(bool Manual); 18 | 19 | u32 ReadMem_gdrom(u32 Addr, u32 sz); 20 | void WriteMem_gdrom(u32 Addr, u32 data, u32 sz); 21 | void FASTCALL NotifyEvent_gdrom(u32 info,void* param); 22 | 23 | #endif //__GDROM_IF_H__ 24 | -------------------------------------------------------------------------------- /nulldc/nullDC/dc/maple/maple_if.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "types.h" 3 | #include "plugins/plugin_manager.h" 4 | 5 | //NEVER touch this name, it was inspired by the great Z 6 | struct eMDevInf 7 | { 8 | MapleDeviceDefinition* mdd; 9 | bool Created; 10 | bool Inited; 11 | }; 12 | extern eMDevInf MapleDevices_dd[4][6]; 13 | 14 | extern maple_device_instance MapleDevices[4]; 15 | 16 | void maple_Init(); 17 | void maple_Reset(bool Manual); 18 | void maple_Term(); 19 | 20 | void maple_vblank(); -------------------------------------------------------------------------------- /nulldc/nullDC/dc/mem/Elf.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skmp/nullDC-v1/1611c3cf0aa2755611455aa7a02b4f62babee7bd/nulldc/nullDC/dc/mem/Elf.h -------------------------------------------------------------------------------- /nulldc/nullDC/dc/mem/_vmem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "types.h" 3 | 4 | //Typedef's 5 | //ReadMem 6 | typedef u8 fastcall _vmem_ReadMem8FP(u32 Address); 7 | typedef u16 fastcall _vmem_ReadMem16FP(u32 Address); 8 | typedef u32 fastcall _vmem_ReadMem32FP(u32 Address); 9 | //WriteMem 10 | typedef void fastcall _vmem_WriteMem8FP(u32 Address,u8 data); 11 | typedef void fastcall _vmem_WriteMem16FP(u32 Address,u16 data); 12 | typedef void fastcall _vmem_WriteMem32FP(u32 Address,u32 data); 13 | 14 | //our own handle type :) 15 | typedef u32 _vmem_handler; 16 | 17 | //Functions 18 | 19 | //init/reset/term 20 | void _vmem_init(); 21 | void _vmem_reset(); 22 | void _vmem_term(); 23 | 24 | //functions to register and map handlers/memory 25 | _vmem_handler _vmem_register_handler(_vmem_ReadMem8FP* read8,_vmem_ReadMem16FP* read16,_vmem_ReadMem32FP* read32, _vmem_WriteMem8FP* write8,_vmem_WriteMem16FP* write16,_vmem_WriteMem32FP* write32); 26 | 27 | #define _vmem_register_handler_Template(read,write) _vmem_register_handler \ 28 | (read<1,u8>,read<2,u16>,read<4,u32>, \ 29 | write<1,u8>,write<2,u16>,write<4,u32>) 30 | 31 | #define _vmem_register_handler_Template1(read,write,extra_Tparam) _vmem_register_handler \ 32 | (read<1,u8,extra_Tparam>,read<2,u16,extra_Tparam>,read<4,u32,extra_Tparam>, \ 33 | write<1,u8,extra_Tparam>,write<2,u16,extra_Tparam>,write<4,u32,extra_Tparam>) 34 | 35 | #define _vmem_register_handler_Template2(read,write,etp1,etp2) _vmem_register_handler \ 36 | (read<1,u8,etp1,etp2>,read<2,u16,etp1,etp2>,read<4,u32,etp1,etp2>, \ 37 | write<1,u8,etp1,etp2>,write<2,u16,etp1,etp2>,write<4,u32,etp1,etp2>) 38 | 39 | void _vmem_map_handler(_vmem_handler Handler,u32 start,u32 end); 40 | void _vmem_map_block(void* base,u32 start,u32 end); 41 | void _vmem_mirror_mapping(u32 new_region,u32 start,u32 size); 42 | 43 | #define _vmem_map_block_mirror(base,start,end,blck_size) {u32 block_size=(blck_size)>>16;u32 map_sz=(end)-(start)+1;verify((map_sz%block_size)==0);/*u32 map_times=map_sz/(block_size);*/ for (u32 _maip=(start);_maip<(end);_maip+=block_size) _vmem_map_block((base),_maip,_maip+block_size-1);} 44 | 45 | //ReadMem(s) 46 | u8 fastcall _vmem_ReadMem8(u32 Address); 47 | u16 fastcall _vmem_ReadMem16(u32 Address); 48 | u32 fastcall _vmem_ReadMem32(u32 Address); 49 | u64 fastcall _vmem_ReadMem64(u32 Address); 50 | //WriteMem(s) 51 | void fastcall _vmem_WriteMem8(u32 Address,u8 data); 52 | void fastcall _vmem_WriteMem16(u32 Address,u16 data); 53 | void fastcall _vmem_WriteMem32(u32 Address,u32 data); 54 | void fastcall _vmem_WriteMem64(u32 Address,u64 data); 55 | 56 | //global reserved mem space 57 | extern u8* sh4_reserved_mem; 58 | extern u8* sh4_ram_alt; //alternative ram space map 59 | //should be called at start up to ensure it will succed:) 60 | bool _vmem_reserve(); 61 | void _vmem_release(); -------------------------------------------------------------------------------- /nulldc/nullDC/dc/mem/memutil.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "types.h" 3 | 4 | #define GDROM_OPCODE ((u16)0x30F9) // GDROMCALL- 0011 0000 1111 1001 5 | 6 | #define patch_syscall_system 32 7 | #define patch_syscall_font 16 8 | #define patch_syscall_flashrom 8 9 | #define patch_syscall_GDrom_misc 4 10 | #define patch_syscall_GDrom_HLE 2 11 | #define patch_resets_Misc 1 12 | #define patch_all 0xFFFFFFFF 13 | 14 | void SetPatches(u32 Value,u32 Mask); 15 | 16 | u32 LoadFileToSh4Mem(u32 offset,wchar*file); 17 | u32 LoadBinfileToSh4Mem(u32 offset,wchar*file); 18 | 19 | 20 | void LoadSyscallHooks(); -------------------------------------------------------------------------------- /nulldc/nullDC/dc/mem/mmu.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "types.h" 3 | #include "dc/sh4/ccn.h" 4 | 5 | struct TLB_Entry 6 | { 7 | CCN_PTEH_type Address; 8 | CCN_PTEL_type Data; 9 | }; 10 | 11 | extern TLB_Entry UTLB[64]; 12 | extern TLB_Entry ITLB[4]; 13 | 14 | //sync mem mapping to mmu , suspend compiled blocks if needed.entry is a UTLB entry # , -1 is for full sync 15 | bool UTLB_SyncMap(u32 entry); 16 | void UTLB_SyncUnmap(u32 entry); 17 | //sync mem mapping to mmu , suspend compiled blocks if needed.entry is a ITLB entry # , -1 is for full sync 18 | void ITLB_Sync(u32 entry); 19 | 20 | 21 | //Do a full lookup on the UTLB entry's 22 | //Return Values 23 | //Translation was sucessfull , rv contains return 24 | #define MMU_ERROR_NONE 0 25 | //TLB miss 26 | #define MMU_ERROR_TLB_MISS 1 27 | //TLB Multyhit 28 | #define MMU_ERROR_TLB_MHIT 2 29 | //Mem is read/write protected (depends on translation type) 30 | #define MMU_ERROR_PROTECTED 3 31 | //Mem is write protected , firstwrite 32 | #define MMU_ERROR_FIRSTWRITE 4 33 | //data-Opcode read/write missasligned 34 | #define MMU_ERROR_BADADDR 5 35 | //Can't Execute 36 | #define MMU_ERROR_EXECPROT 6 37 | 38 | //Translation Types 39 | //Opcode read 40 | #define MMU_TT_IREAD 0 41 | //Data write 42 | #define MMU_TT_DWRITE 1 43 | //Data write 44 | #define MMU_TT_DREAD 2 45 | //Do an mmu lookup for va , returns translation status , if MMU_ERROR_NONE , rv is set to translated index 46 | 47 | extern u32 mmu_error_TT; 48 | 49 | void MMU_Init(); 50 | void MMU_Reset(bool Manual); 51 | void MMU_Term(); 52 | 53 | u8 __fastcall mmu_ReadMem8(u32 addr); 54 | u16 __fastcall mmu_ReadMem16(u32 addr); 55 | u16 __fastcall mmu_IReadMem16(u32 addr); 56 | u32 __fastcall mmu_ReadMem32(u32 addr); 57 | u64 __fastcall mmu_ReadMem64(u32 addr); 58 | 59 | void __fastcall mmu_WriteMem8(u32 addr,u8 data); 60 | void __fastcall mmu_WriteMem16(u32 addr,u16 data); 61 | void __fastcall mmu_WriteMem32(u32 addr,u32 data); 62 | void __fastcall mmu_WriteMem64(u32 addr,u64 data); 63 | bool __fastcall mmu_TranslateSQW(u32& addr); -------------------------------------------------------------------------------- /nulldc/nullDC/dc/mem/sh4_area0.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "types.h" 3 | 4 | void map_area0_init(); 5 | void map_area0(u32 base); 6 | 7 | //Init/Res/Term 8 | void sh4_area0_Init(); 9 | void sh4_area0_Reset(bool Manual); 10 | void sh4_area0_Term(); -------------------------------------------------------------------------------- /nulldc/nullDC/dc/pvr/pvrLock.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types.h" 4 | 5 | //16 mb for naomi.. so be carefull not to hardcode it anywhere 6 | 7 | 8 | #define Is_64_Bit(addr) ((addr &0x1000000)==0) 9 | 10 | //vram_block, vramLockCBFP on plugin headers 11 | 12 | 13 | u32 vramlock_ConvAddrtoOffset64(u32 Address); 14 | u32 vramlock_ConvOffset32toOffset64(u32 offset32); 15 | 16 | void FASTCALL vramlock_Unlock_block(vram_block* block); 17 | vram_block* FASTCALL vramlock_Lock_32(u32 start_offset32,u32 end_offset32,void* userdata); 18 | vram_block* FASTCALL vramlock_Lock_64(u32 start_offset64,u32 end_offset64,void* userdata); 19 | 20 | void vram_LockedWrite(u32 offset64); -------------------------------------------------------------------------------- /nulldc/nullDC/dc/pvr/pvr_if.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "types.h" 3 | #include "plugins/plugin_manager.h" 4 | 5 | 6 | //pvr plugins 7 | bool SetPvrPlugin(nullDC_PowerVR_plugin* plg); 8 | 9 | //regs 10 | u32 pvr_readreg_TA(u32 addr,u32 sz); 11 | void pvr_writereg_TA(u32 addr,u32 data,u32 sz); 12 | 13 | //vram 32-64b 14 | extern VArray2 vram; 15 | //read 16 | u8 __fastcall pvr_read_area1_8(u32 addr); 17 | u16 __fastcall pvr_read_area1_16(u32 addr); 18 | u32 __fastcall pvr_read_area1_32(u32 addr); 19 | //write 20 | void __fastcall pvr_write_area1_8(u32 addr,u8 data); 21 | void __fastcall pvr_write_area1_16(u32 addr,u16 data); 22 | void __fastcall pvr_write_area1_32(u32 addr,u32 data); 23 | 24 | void pvr_Update(u32 cycles); 25 | 26 | //Init/Term , global 27 | void pvr_Init(); 28 | void pvr_Term(); 29 | //Reset -> Reset - Initialise 30 | void pvr_Reset(bool Manual); 31 | 32 | void FASTCALL TAWrite(u32 address,u32* data,u32 count); 33 | void FASTCALL TAWriteSQ(u32 address,u32* data); 34 | 35 | // 36 | #define UpdatePvr(clc) libPvr.UpdatePvr(clc) 37 | 38 | 39 | //registers 40 | #define PVR_BASE 0x005F8000 -------------------------------------------------------------------------------- /nulldc/nullDC/dc/pvr/pvr_sb_regs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "types.h" 3 | 4 | //regs 5 | u32 pvr_sb_readreg_Pvr(u32 addr,u32 sz); 6 | void pvr_sb_writereg_Pvr(u32 addr,u32 data,u32 sz); 7 | 8 | //Init/Term , global 9 | void pvr_sb_Init(); 10 | void pvr_sb_Term(); 11 | //Reset -> Reset - Initialise 12 | void pvr_sb_Reset(bool Manual); -------------------------------------------------------------------------------- /nulldc/nullDC/dc/sh4/ccn.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types.h" 4 | 5 | //Init/Res/Term 6 | void ccn_Init(); 7 | void ccn_Reset(bool Manual); 8 | void ccn_Term(); 9 | 10 | union CCN_PTEH_type 11 | { 12 | struct 13 | { 14 | u32 ASID:8; //0-7 ASID 15 | u32 res:2; //8,9 reserved 16 | u32 VPN:22; //10-31 VPN 17 | }; 18 | u32 reg_data; 19 | }; 20 | 21 | union CCN_PTEL_type 22 | { 23 | struct 24 | { 25 | u32 WT:1; 26 | u32 SH:1; 27 | u32 D :1; 28 | u32 C :1; 29 | 30 | u32 SZ0:1; 31 | u32 PR :2; 32 | u32 SZ1:1; 33 | 34 | u32 V:1; 35 | u32 res_0:1; 36 | u32 PPN:19;//PPN 10-28 37 | u32 res_1:3; 38 | }; 39 | u32 reg_data; 40 | }; 41 | 42 | union CCN_MMUCR_type 43 | { 44 | struct 45 | { 46 | u32 AT:1; 47 | u32 res:1; 48 | u32 TI:1; 49 | u32 res_2:5; 50 | u32 SV:1; 51 | u32 SQMD:1; 52 | u32 URC:6; 53 | u32 URB:6; 54 | u32 LRUI:6; 55 | }; 56 | u32 reg_data; 57 | }; 58 | 59 | union CCN_PTEA_type 60 | { 61 | struct 62 | { 63 | u32 SA:3; 64 | u32 TC:1; 65 | u32 res:28; 66 | }; 67 | u32 reg_data; 68 | }; 69 | 70 | union CCN_CCR_type 71 | { 72 | struct 73 | { 74 | u32 OCE:1; 75 | u32 WT:1; 76 | u32 CB:1; 77 | u32 OCI:1; 78 | u32 res:1; 79 | u32 ORA:1; 80 | u32 res_1:1; 81 | u32 OIX:1; 82 | u32 ICE:1; 83 | u32 res_2:2; 84 | u32 ICI:1; 85 | u32 res_3:3; 86 | u32 IIX:1; 87 | u32 res_4:16; 88 | }; 89 | u32 reg_data; 90 | }; 91 | 92 | union CCN_QACR_type 93 | { 94 | struct 95 | { 96 | u32 res:2; 97 | u32 Area:3; 98 | u32 res_1:27; 99 | }; 100 | u32 reg_data; 101 | }; 102 | 103 | 104 | //Types 105 | extern CCN_PTEH_type CCN_PTEH; 106 | extern CCN_PTEL_type CCN_PTEL; 107 | extern u32 CCN_TTB; 108 | extern u32 CCN_TEA; 109 | extern CCN_MMUCR_type CCN_MMUCR; 110 | extern u8 CCN_BASRA; 111 | extern u8 CCN_BASRB; 112 | extern CCN_CCR_type CCN_CCR; 113 | extern u32 CCN_TRA; 114 | extern u32 CCN_EXPEVT; 115 | extern u32 CCN_INTEVT; 116 | extern CCN_PTEA_type CCN_PTEA; 117 | extern CCN_QACR_type CCN_QACR[2]; 118 | extern u32 CCN_QACR_TR[2]; -------------------------------------------------------------------------------- /nulldc/nullDC/dc/sh4/cpg.cpp: -------------------------------------------------------------------------------- 1 | #include "types.h" 2 | #include "dc/mem/sh4_internal_reg.h" 3 | #include "cpg.h" 4 | 5 | 6 | u16 CPG_FRQCR; 7 | u8 CPG_STBCR; 8 | u16 CPG_WTCNT; 9 | u16 CPG_WTCSR; 10 | u8 CPG_STBCR2; 11 | 12 | //Init term res 13 | void cpg_Init() 14 | { 15 | //CPG FRQCR H'FFC0 0000 H'1FC0 0000 16 *2 Held Held Held Pclk 16 | CPG[(CPG_FRQCR_addr&0xFF)>>2].flags=REG_16BIT_READWRITE | REG_READ_DATA | REG_WRITE_DATA; 17 | CPG[(CPG_FRQCR_addr&0xFF)>>2].readFunction=0; 18 | CPG[(CPG_FRQCR_addr&0xFF)>>2].writeFunction=0; 19 | CPG[(CPG_FRQCR_addr&0xFF)>>2].data16=&CPG_FRQCR; 20 | 21 | //CPG STBCR H'FFC0 0004 H'1FC0 0004 8 H'00 Held Held Held Pclk 22 | CPG[(CPG_STBCR_addr&0xFF)>>2].flags=REG_8BIT_READWRITE | REG_READ_DATA | REG_WRITE_DATA; 23 | CPG[(CPG_STBCR_addr&0xFF)>>2].readFunction=0; 24 | CPG[(CPG_STBCR_addr&0xFF)>>2].writeFunction=0; 25 | CPG[(CPG_STBCR_addr&0xFF)>>2].data8=&CPG_STBCR; 26 | 27 | //CPG WTCNT H'FFC0 0008 H'1FC0 0008 8/16*3 H'00 Held Held Held Pclk 28 | CPG[(CPG_WTCNT_addr&0xFF)>>2].flags=REG_16BIT_READWRITE | REG_READ_DATA | REG_WRITE_DATA; 29 | CPG[(CPG_WTCNT_addr&0xFF)>>2].readFunction=0; 30 | CPG[(CPG_WTCNT_addr&0xFF)>>2].writeFunction=0; 31 | CPG[(CPG_WTCNT_addr&0xFF)>>2].data16=&CPG_WTCNT; 32 | 33 | //CPG WTCSR H'FFC0 000C H'1FC0 000C 8/16*3 H'00 Held Held Held Pclk 34 | CPG[(CPG_WTCSR_addr&0xFF)>>2].flags=REG_16BIT_READWRITE | REG_READ_DATA | REG_WRITE_DATA; 35 | CPG[(CPG_WTCSR_addr&0xFF)>>2].readFunction=0; 36 | CPG[(CPG_WTCSR_addr&0xFF)>>2].writeFunction=0; 37 | CPG[(CPG_WTCSR_addr&0xFF)>>2].data16=&CPG_WTCSR; 38 | 39 | //CPG STBCR2 H'FFC0 0010 H'1FC0 0010 8 H'00 Held Held Held Pclk 40 | CPG[(CPG_STBCR2_addr&0xFF)>>2].flags=REG_8BIT_READWRITE | REG_READ_DATA | REG_WRITE_DATA; 41 | CPG[(CPG_STBCR2_addr&0xFF)>>2].readFunction=0; 42 | CPG[(CPG_STBCR2_addr&0xFF)>>2].writeFunction=0; 43 | CPG[(CPG_STBCR2_addr&0xFF)>>2].data8=&CPG_STBCR2; 44 | 45 | 46 | } 47 | void cpg_Reset(bool Manual) 48 | { 49 | /* 50 | CPG FRQCR H'FFC0 0000 H'1FC0 0000 16 *2 Held Held Held Pclk 51 | CPG STBCR H'FFC0 0004 H'1FC0 0004 8 H'00 Held Held Held Pclk 52 | CPG WTCNT H'FFC0 0008 H'1FC0 0008 8/16*3 H'00 Held Held Held Pclk 53 | CPG WTCSR H'FFC0 000C H'1FC0 000C 8/16*3 H'00 Held Held Held Pclk 54 | CPG STBCR2 H'FFC0 0010 H'1FC0 0010 8 H'00 Held Held Held Pclk 55 | */ 56 | CPG_FRQCR = 0; 57 | CPG_STBCR = 0; 58 | CPG_WTCNT = 0; 59 | CPG_WTCSR = 0; 60 | CPG_STBCR2 = 0; 61 | 62 | } 63 | void cpg_Term() 64 | { 65 | } -------------------------------------------------------------------------------- /nulldc/nullDC/dc/sh4/cpg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types.h" 4 | 5 | //Init/Res/Term 6 | void cpg_Init(); 7 | void cpg_Reset(bool Manual); 8 | void cpg_Term(); 9 | 10 | extern u16 CPG_FRQCR; 11 | extern u8 CPG_STBCR; 12 | extern u16 CPG_WTCNT; 13 | extern u16 CPG_WTCSR; 14 | extern u8 CPG_STBCR2; -------------------------------------------------------------------------------- /nulldc/nullDC/dc/sh4/dmac.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skmp/nullDC-v1/1611c3cf0aa2755611455aa7a02b4f62babee7bd/nulldc/nullDC/dc/sh4/dmac.h -------------------------------------------------------------------------------- /nulldc/nullDC/dc/sh4/intc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types.h" 4 | #include "sh4_if.h" 5 | 6 | 7 | //Enums 8 | 9 | void SetInterruptPend(InterruptID intr); 10 | void ResetInterruptPend(InterruptID intr); 11 | #define InterruptPend(intr,v) ((v)==0?ResetInterruptPend(intr):SetInterruptPend(intr)) 12 | 13 | void SetInterruptMask(InterruptID intr); 14 | void ResetInterruptMask(InterruptID intr); 15 | #define InterruptMask(intr,v) ((v)==0?ResetInterruptMask(intr):SetInterruptMask(intr)) 16 | 17 | int UpdateINTC(); 18 | void FASTCALL RaiseInterrupt_(InterruptID intr); 19 | void RaiseExeption(u32 code,u32 vector); 20 | bool Do_Exeption(u32 lvl, u32 expEvn, u32 CallVect); 21 | 22 | union INTC_ICR_type 23 | { 24 | u16 reg_data; 25 | struct 26 | { 27 | u32 res:7; 28 | u32 IRLM:1; 29 | u32 NMIE:1; 30 | u32 NMIB:1; 31 | u32 res_2:4; 32 | u32 MAI:1; 33 | u32 NMIL:1; 34 | }; 35 | }; 36 | 37 | union INTC_IPRA_type 38 | { 39 | u16 reg_data; 40 | struct 41 | { 42 | u32 RTC:4; 43 | u32 TMU2:4; 44 | u32 TMU1:4; 45 | u32 TMU0:4; 46 | }; 47 | }; 48 | 49 | union INTC_IPRB_type 50 | { 51 | u16 reg_data; 52 | struct 53 | { 54 | u32 Reserved:4; 55 | u32 SCI1:4; 56 | u32 REF:4; 57 | u32 WDT:4; 58 | }; 59 | }; 60 | 61 | union INTC_IPRC_type 62 | { 63 | u16 reg_data; 64 | struct 65 | { 66 | u32 Hitachi_UDI:4; 67 | u32 SCIF:4; 68 | u32 DMAC:4; 69 | u32 GPIO:4; 70 | }; 71 | }; 72 | 73 | typedef u32 GetPrLvlFP(void); 74 | 75 | struct InterptSourceList_Entry 76 | { 77 | GetPrLvlFP* GetPrLvl; 78 | u32 IntEvnCode; 79 | }; 80 | 81 | 82 | 83 | extern INTC_ICR_type INTC_ICR; 84 | extern INTC_IPRA_type INTC_IPRA; 85 | extern INTC_IPRB_type INTC_IPRB; 86 | extern INTC_IPRC_type INTC_IPRC; 87 | 88 | void intc_Init(); 89 | void intc_Reset(bool Manual); 90 | void intc_Term(); 91 | 92 | bool SRdecode(); 93 | -------------------------------------------------------------------------------- /nulldc/nullDC/dc/sh4/rec_v1/analyser.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "recompiler.h" 3 | #include "BasicBlock.h" 4 | #include "ops.h" 5 | #include "dc\sh4\sh4_opcode_list.h" 6 | 7 | 8 | void ScanCode(u32 pc,CodeRegion* to); 9 | void AnalyseCode(BasicBlock* to); 10 | 11 | //Init/Reset/Term 12 | void InitAnalyser(); 13 | void ResetAnalyser(); 14 | void TermAnalyser(); -------------------------------------------------------------------------------- /nulldc/nullDC/dc/sh4/rec_v1/blockmanager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "types.h" 3 | #include "recompiler.h" 4 | #include "compiledblock.h" 5 | 6 | struct pginfo 7 | { 8 | u32 invalidates; 9 | union 10 | { 11 | struct 12 | { 13 | u32 ManualCheck:1; //bit 0 :1-> manual check , 0 -> locked check 14 | u32 reserved:31; //bit 1-31: reserved 15 | }; 16 | u32 full; 17 | } flags; 18 | }; 19 | 20 | extern u32* block_stack_pointer; 21 | 22 | #define PAGE_MANUALCHECK 1 23 | pginfo GetPageInfo(u32 address); 24 | 25 | #define FindBlock FindBlock_fast 26 | #define FindCode FindCode_fast 27 | 28 | CompiledBlockInfo* __fastcall FindBlock_fast(u32 address); 29 | BasicBlockEP* __fastcall FindCode_fast(u32 address); 30 | 31 | void RegisterBlock(CompiledBlockInfo* block); 32 | void UnRegisterBlock(CompiledBlockInfo* block); 33 | CompiledBlockInfo* bm_ReverseLookup(void* code_ptr); 34 | 35 | void FreeSuspendedBlocks(); 36 | 37 | CompiledBlockInfo* FindOrRecompileBlock(u32 pc); 38 | void __fastcall SuspendBlock(CompiledBlockInfo* block); 39 | void __fastcall SuspendAllBlocks(); 40 | void __fastcall _SuspendAllBlocks(); 41 | CompiledBlockInfo* __fastcall FindBlock_full_compile(u32 address,CompiledBlockInfo* fastblock); 42 | 43 | void InitBlockManager(); 44 | void ResetBlockManager(); 45 | void TermBlockManager(); 46 | 47 | extern u8* DynarecCache; 48 | extern u32 DynarecCacheSize; 49 | 50 | void* dyna_malloc(u32 size); 51 | void* dyna_realloc(void*ptr,u32 oldsize,u32 newsize); 52 | void* dyna_finalize(void* ptr,u32 oldsize,u32 newsize); 53 | void dyna_profiler_tick(void* addr); 54 | 55 | struct bm_stats 56 | { 57 | u32 block_count; 58 | u32 block_size; 59 | u32 cache_size; 60 | u64 CompileTimeMilisecs; 61 | 62 | u32 locked_blocks; 63 | u32 locked_block_calls_delta; 64 | 65 | u32 manual_blocks; 66 | u32 manual_block_calls_delta; 67 | 68 | u32 full_lookups; 69 | u32 fast_lookups; 70 | }; 71 | 72 | void bm_GetStats(bm_stats* stats); 73 | 74 | //#define _BM_CACHE_STATS 75 | #define LOOKUP_HASH_SIZE 0x4000 76 | #define LOOKUP_HASH_MASK (LOOKUP_HASH_SIZE-1) 77 | extern CompiledBlockInfo* BlockLookupGuess[LOOKUP_HASH_SIZE]; 78 | 79 | //#define COUNT_BLOCK_LOCKTYPE_USAGE 80 | extern u32 manbs; 81 | extern u32 lockbs; 82 | -------------------------------------------------------------------------------- /nulldc/nullDC/dc/sh4/rec_v1/codespan.cpp: -------------------------------------------------------------------------------- 1 | #include "codespan.h" 2 | #include "dc/mem/sh4_mem.h" 3 | 4 | //start page , olny valid if in ram 5 | u32 CodeSpan::page_start() 6 | { 7 | return GetRamPageFromAddress(start); 8 | } 9 | //end page , olny valid if in ram 10 | u32 CodeSpan::page_end() 11 | { 12 | return GetRamPageFromAddress(end); 13 | } 14 | //True if block is on ram :) 15 | bool CodeSpan::OnRam() 16 | { 17 | //code can't start and end on diff mem areas , so olny check start :) 18 | return IsOnRam(start); 19 | } 20 | //Retuns the size of the code span (in bytes) 21 | u32 CodeSpan::Size() 22 | { 23 | return end-start+2; 24 | } 25 | 26 | //Returns the opcode count of the code span 27 | u32 CodeSpan::OpcodeCount() 28 | { 29 | return Size()>>1; 30 | } 31 | 32 | 33 | //Returns the Page count of the code span [olny valid if in vram] 34 | u32 CodeSpan::PageCount() 35 | { 36 | verify(OnRam()); 37 | return page_end()-page_start()+1; 38 | } 39 | //Checks if this CodeSpan contains an adress.Valid olny if on block is on ram and address is on ram :) 40 | bool CodeSpan::Contains(u32 address,u32 sz) 41 | { 42 | verify(OnRam() && IsOnRam(address)); 43 | u32 r_address=address&RAM_MASK; 44 | u32 r_start=start&RAM_MASK; 45 | u32 r_end=end&RAM_MASK; 46 | 47 | return r_start<=r_address && (r_address+sz)<=r_end; 48 | } 49 | 50 | //checks if this CodeSpan contains another Codespan 51 | bool CodeSpan::Contains(CodeSpan* to) 52 | { 53 | verify(OnRam() && to->OnRam()); 54 | return Contains(to->start,2) && Contains(to->end,2); 55 | } 56 | 57 | //Checks if this CodeSpan contains an adress , counting in page units. 58 | bool CodeSpan::ContainsPage(u32 address) 59 | { 60 | verify(OnRam() && IsOnRam(address)); 61 | u32 r_address=GetRamPageFromAddress(address); 62 | u32 r_start=page_start(); 63 | u32 r_end=page_end(); 64 | 65 | return r_start<=r_address && r_address<=r_end; 66 | } 67 | 68 | //Checks if this CodeSpan contains another code span , counting in page units. 69 | bool CodeSpan::ContainsPage(CodeSpan* to) 70 | { 71 | verify(OnRam() && to->OnRam()); 72 | return ContainsPage(to->start) && ContainsPage(to->end); 73 | } 74 | 75 | //Creates a Union w/ the CodeSpan , assuming this CodeSpan is on ram.The to codespan contains decoded ram offsets 76 | void CodeSpan::Union(CodeSpan* to) 77 | { 78 | verify(OnRam()); 79 | to->start=min(to->start&RAM_MASK,start&RAM_MASK); 80 | to->start=max(to->end&RAM_MASK,end&RAM_MASK); 81 | } 82 | 83 | //Checks if this CodeSpan Intersects w/ another , assuming both are on ram 84 | bool CodeSpan::Intersect(CodeSpan* to) 85 | { 86 | verify(OnRam() && to->OnRam()); 87 | u32 cr_start=start&RAM_MASK; 88 | u32 cr_end=end&RAM_MASK; 89 | 90 | u32 tr_start=to->start&RAM_MASK; 91 | u32 tr_end=to->end&RAM_MASK; 92 | 93 | //in order not to inersect , the block must be before (this-> start < to-> end) or after (this->end start) 94 | return !(cr_start not anymore] 61 | void* pTF_next_addr;//tfalse or jmp or jmp guess 62 | void* pTT_next_addr;//ttrue or rts guess 63 | 64 | struct 65 | { 66 | u32 Offset; //bytes after block start for rewrite 67 | u8 Type:2; //Type (0-> none, 1 -> COND, 2-> Fixed, 3 -> wtf 68 | u8 RCFlags:6; //rewrite code flags (values: private to handler, default = 0) 69 | u8 Last; //last rewrite parameters (values: private to handler,default 0xFF) 70 | }Rewrite; 71 | //Block link info 72 | vector blocks_to_clear; 73 | }; -------------------------------------------------------------------------------- /nulldc/nullDC/dc/sh4/rec_v1/driver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "types.h" 3 | 4 | 5 | 6 | //interface 7 | void rec_Sh4_int_Run(); 8 | void rec_Sh4_int_Stop(); 9 | void rec_Sh4_int_Step(); 10 | void rec_Sh4_int_Skip(); 11 | void rec_Sh4_int_Reset(bool Manual); 12 | void rec_Sh4_int_Init(); 13 | void rec_Sh4_int_Term(); 14 | bool rec_Sh4_int_IsCpuRunning(); 15 | void rec_sh4_ResetCache(); 16 | void __fastcall rec_sh4_int_RaiseExeption(u32 ExeptionCode,u32 VectorAddress); -------------------------------------------------------------------------------- /nulldc/nullDC/dc/sh4/rec_v1/recompiler.h: -------------------------------------------------------------------------------- 1 | //Global header for v1 dynarec 2 | #pragma once 3 | #include 4 | #include "types.h" 5 | //#include "dc\sh4\shil\shil.h" 6 | 7 | //count fallbacks and average block size, average execution time , ect :) 8 | //#define PROFILE_DYNAREC 9 | //#define RET_CACHE_PROF 10 | extern u32 ret_cache_hits; 11 | extern u32 ret_cache_total; 12 | 13 | void printprofile(); 14 | 15 | typedef void BasicBlockEP(); 16 | 17 | extern void* Dynarec_Mainloop_no_update; 18 | extern void* Dynarec_Mainloop_do_update; 19 | extern u32 rec_cycles; 20 | 21 | #define GET_CURRENT_FPU_MODE() (fpscr.PR_SZ) 22 | 23 | #define BLOCKLIST_MAX_CYCLES (448) 24 | 25 | 26 | /* 27 | //shit i gota put somewhere 28 | 29 | */ -------------------------------------------------------------------------------- /nulldc/nullDC/dc/sh4/rec_v1/sh4_cpu_shil.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "types.h" 3 | #include "dc/sh4/shil/shil.h" 4 | #include "BasicBlock.h" 5 | 6 | void shil_DynarecInit(); 7 | bool __fastcall Scanner_FindSOM(u32 opcode,u32 pc,u32* SOM); 8 | extern shil_stream* ilst; -------------------------------------------------------------------------------- /nulldc/nullDC/dc/sh4/rec_v1/sh4_fpu_shil.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "types.h" 3 | -------------------------------------------------------------------------------- /nulldc/nullDC/dc/sh4/rtc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types.h" 4 | 5 | //Init/Res/Term 6 | void rtc_Init(); 7 | void rtc_Reset(bool Manual); 8 | void rtc_Term(); -------------------------------------------------------------------------------- /nulldc/nullDC/dc/sh4/sci.cpp: -------------------------------------------------------------------------------- 1 | #include "types.h" 2 | #include "dc/mem/sh4_internal_reg.h" 3 | #include "sci.h" 4 | 5 | 6 | //Init term res 7 | void sci_Init() 8 | { 9 | } 10 | void sci_Reset(bool Manual) 11 | { 12 | } 13 | void sci_Term() 14 | { 15 | } -------------------------------------------------------------------------------- /nulldc/nullDC/dc/sh4/sci.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types.h" 4 | 5 | //Init/Res/Term 6 | void sci_Init(); 7 | void sci_Reset(bool Manual); 8 | void sci_Term(); -------------------------------------------------------------------------------- /nulldc/nullDC/dc/sh4/sh4_cpu_arith.h: -------------------------------------------------------------------------------- 1 | /* 2 | sh4 base core 3 | most of it is (very) old 4 | could use many cleanups, lets hope someone does them 5 | */ 6 | 7 | // sub , 8 | sh4op(i0011_nnnn_mmmm_1000) 9 | { 10 | u32 n = GetN(op); 11 | u32 m = GetM(op); 12 | //rn=(s32)r[n]; 13 | //rm=(s32)r[m]; 14 | r[n] -=r[m]; 15 | //r[n]=(u32)rn; 16 | } 17 | 18 | //add , 19 | sh4op(i0011_nnnn_mmmm_1100) 20 | { 21 | u32 n = GetN(op); 22 | u32 m = GetM(op); 23 | r[n] +=r[m]; 24 | } 25 | 26 | // 27 | // 7xxx 28 | 29 | //add #, 30 | sh4op(i0111_nnnn_iiii_iiii) 31 | { 32 | u32 n = GetN(op); 33 | s32 stmp1 = GetSImm8(op); 34 | r[n] +=stmp1; 35 | } 36 | -------------------------------------------------------------------------------- /nulldc/nullDC/dc/sh4/sh4_cpu_branch_rec.h: -------------------------------------------------------------------------------- 1 | //All branches have to be rewriten for the recompiler 2 | 3 | -------------------------------------------------------------------------------- /nulldc/nullDC/dc/sh4/sh4_cpu_logic.h: -------------------------------------------------------------------------------- 1 | /* 2 | sh4 base core 3 | most of it is (very) old 4 | could use many cleanups, lets hope someone does them 5 | */ 6 | 7 | //Bitwise logical operations 8 | // 9 | 10 | //and , 11 | sh4op(i0010_nnnn_mmmm_1001) 12 | { 13 | u32 n = GetN(op); 14 | u32 m = GetM(op); 15 | r[n] &= r[m]; 16 | } 17 | 18 | //xor , 19 | sh4op(i0010_nnnn_mmmm_1010) 20 | { 21 | u32 n = GetN(op); 22 | u32 m = GetM(op); 23 | r[n] ^= r[m]; 24 | } 25 | 26 | //or , 27 | sh4op(i0010_nnnn_mmmm_1011) 28 | { 29 | u32 n = GetN(op); 30 | u32 m = GetM(op); 31 | r[n] |= r[m]; 32 | } 33 | 34 | 35 | //shll2 36 | sh4op(i0100_nnnn_0000_1000) 37 | { 38 | u32 n = GetN(op); 39 | r[n] <<= 2; 40 | } 41 | 42 | 43 | //shll8 44 | sh4op(i0100_nnnn_0001_1000) 45 | {//ToDo : Check This [26/4/05] 46 | u32 n = GetN(op); 47 | r[n] <<= 8; 48 | } 49 | 50 | 51 | //shll16 52 | sh4op(i0100_nnnn_0010_1000) 53 | {//ToDo : Check This [26/4/05] 54 | u32 n = GetN(op); 55 | r[n] <<= 16; 56 | } 57 | 58 | 59 | //shlr2 60 | sh4op(i0100_nnnn_0000_1001) 61 | {//ToDo : Check This [26/4/05] 62 | u32 n = GetN(op); 63 | r[n] >>= 2; 64 | } 65 | 66 | 67 | //shlr8 68 | sh4op(i0100_nnnn_0001_1001) 69 | { 70 | //iNimp("shlr8 "); 71 | u32 n = GetN(op); 72 | r[n] >>= 8; 73 | } 74 | 75 | 76 | //shlr16 77 | sh4op(i0100_nnnn_0010_1001) 78 | { 79 | u32 n = GetN(op); 80 | r[n] >>= 16; 81 | } 82 | 83 | // and #,R0 84 | sh4op(i1100_1001_iiii_iiii) 85 | {//ToDo : Check This [26/4/05] 86 | //iNimp("and #,R0"); 87 | u32 imm = GetImm8(op); 88 | r[0] &= imm; 89 | } 90 | 91 | 92 | // xor #,R0 93 | sh4op(i1100_1010_iiii_iiii) 94 | { 95 | //iNimp("xor #,R0"); 96 | u32 imm = GetImm8(op); 97 | r[0] ^= imm; 98 | } 99 | 100 | 101 | // or #,R0 102 | sh4op(i1100_1011_iiii_iiii) 103 | {//ToDo : Check This [26/4/05] 104 | //iNimp("or #,R0"); 105 | u32 imm = GetImm8(op); 106 | r[0] |= imm; 107 | } 108 | 109 | 110 | 111 | //TODO : move it somewhere better 112 | //nop 113 | sh4op(i0000_0000_0000_1001) 114 | { 115 | //no operation xD XD .. i just love this opcode .. 116 | //what ? you expected something fancy or smth ? 117 | } 118 | 119 | -------------------------------------------------------------------------------- /nulldc/nullDC/dc/sh4/sh4_fpu.h: -------------------------------------------------------------------------------- 1 | /* 2 | sh4 base core 3 | most of it is (very) old 4 | could use many cleanups, lets hope someone does them 5 | */ 6 | 7 | #pragma once 8 | #include "types.h" 9 | #include "sh4_interpreter.h" 10 | 11 | //fadd , 12 | sh4op(i1111_nnnn_mmmm_0000); 13 | //fsub , 14 | sh4op(i1111_nnnn_mmmm_0001); 15 | //fmul , 16 | sh4op(i1111_nnnn_mmmm_0010); 17 | //fdiv , 18 | sh4op(i1111_nnnn_mmmm_0011); 19 | //fcmp/eq , 20 | sh4op(i1111_nnnn_mmmm_0100); 21 | //fcmp/gt , 22 | sh4op(i1111_nnnn_mmmm_0101); 23 | //fmov.s @(R0,), 24 | sh4op(i1111_nnnn_mmmm_0110); 25 | //fmov.s ,@(R0,) 26 | sh4op(i1111_nnnn_mmmm_0111); 27 | //fmov.s @, 28 | sh4op(i1111_nnnn_mmmm_1000); 29 | //fmov.s @+, 30 | sh4op(i1111_nnnn_mmmm_1001); 31 | //fmov.s ,@ 32 | sh4op(i1111_nnnn_mmmm_1010); 33 | //fmov.s ,@- 34 | sh4op(i1111_nnnn_mmmm_1011); 35 | //fmov , 36 | sh4op(i1111_nnnn_mmmm_1100); 37 | //fabs 38 | sh4op(i1111_nnnn_0101_1101); 39 | // FSCA FPUL, DRn//F0FD//1111_nnnn_1111_1101 40 | sh4op(i1111_nnn0_1111_1101); 41 | //fcnvds ,FPUL 42 | sh4op(i1111_nnnn_1011_1101); 43 | //fcnvsd FPUL, 44 | sh4op(i1111_nnnn_1010_1101); 45 | //fipr , 46 | sh4op(i1111_nnmm_1110_1101); 47 | //fldi0 48 | sh4op(i1111_nnnn_1000_1101); 49 | //fldi1 50 | sh4op(i1111_nnnn_1001_1101); 51 | //flds ,FPUL 52 | sh4op(i1111_nnnn_0001_1101); 53 | //float FPUL, 54 | sh4op(i1111_nnnn_0010_1101); 55 | //fneg 56 | sh4op(i1111_nnnn_0100_1101); 57 | //frchg 58 | sh4op(i1111_1011_1111_1101); 59 | //fschg 60 | sh4op(i1111_0011_1111_1101); 61 | //fsqrt 62 | sh4op(i1111_nnnn_0110_1101); 63 | //ftrc , FPUL 64 | sh4op(i1111_nnnn_0011_1101); 65 | //fsts FPUL, 66 | sh4op(i1111_nnnn_0000_1101); 67 | //fmac ,, 68 | sh4op(i1111_nnnn_mmmm_1110); 69 | //ftrv xmtrx, 70 | sh4op(i1111_nn01_1111_1101); 71 | //FSRRA 72 | sh4op(i1111_nnnn_0111_1101); -------------------------------------------------------------------------------- /nulldc/nullDC/dc/sh4/sh4_if.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Glue code for sh4 interface stuff 3 | */ 4 | #include "types.h" 5 | #include "sh4_if.h" 6 | #include "sh4_interpreter.h" 7 | #include "rec_v1\driver.h" 8 | 9 | //sh4 exeption saved stack pointer :) 10 | u32* sh4_exept_ssp; 11 | //sh4 next opcode execute 12 | u32* sh4_exept_next; 13 | //sh4 exeption raised bool , set to true when an exeption was raised , and its not handled 14 | bool sh4_exept_raised=false; 15 | 16 | u8 GetSingleFromDouble(u8 dbl) 17 | { 18 | if (dbl>=dr_0 && dbl<=dr_7) 19 | { 20 | u8 res=(u8)(dbl-dr_0); 21 | return (u8)(fr_0+(res<<1)); 22 | } 23 | else if (dbl>=xd_0 && dbl<=xd_7) 24 | { 25 | u8 res=(u8)(dbl-xd_0); 26 | return (u8)(xf_0+(res<<1)); 27 | } 28 | 29 | log("GetSingleFromDouble : WRONG ID %X\n",dbl); 30 | 31 | return reg_xmtrx;//error :P 32 | } 33 | 34 | bool IsReg64(Sh4RegType reg) 35 | { 36 | if (reg>=dr_0 && reg<=dr_7) 37 | return true; 38 | 39 | if (reg>=xd_0 && reg<=xd_7) 40 | return true; 41 | 42 | return false; 43 | } 44 | //what to put here ? 45 | //Ahh i know i know :P 46 | 47 | //Get an interface to sh4 interpreter 48 | sh4_if* Get_Sh4Interpreter() 49 | { 50 | sh4_if* rv=(sh4_if*)malloc(sizeof(sh4_if)); 51 | 52 | rv->Run=Sh4_int_Run; 53 | rv->Stop=Sh4_int_Stop; 54 | rv->Step=Sh4_int_Step; 55 | rv->Skip=Sh4_int_Skip; 56 | rv->Reset=Sh4_int_Reset; 57 | rv->Init=Sh4_int_Init; 58 | rv->Term=Sh4_int_Term; 59 | rv->IsCpuRunning=Sh4_int_IsCpuRunning; 60 | rv->GetRegister=Sh4_int_GetRegister; 61 | rv->SetRegister=Sh4_int_SetRegister; 62 | //rv->RaiseInterrupt=RaiseInterrupt_; 63 | rv->RaiseExeption=sh4_int_RaiseExeption; 64 | rv->ResetCache=0; 65 | return rv; 66 | } 67 | 68 | //Get an interface to sh4 dynarec 69 | sh4_if* Get_Sh4Recompiler() 70 | { 71 | sh4_if* rv=(sh4_if*)malloc(sizeof(sh4_if)); 72 | 73 | rv->Run=rec_Sh4_int_Run; 74 | rv->Stop=rec_Sh4_int_Stop; 75 | rv->Step=rec_Sh4_int_Step; 76 | rv->Skip=rec_Sh4_int_Skip; 77 | rv->Reset=rec_Sh4_int_Reset; 78 | rv->Init=rec_Sh4_int_Init; 79 | rv->Term=rec_Sh4_int_Term; 80 | rv->IsCpuRunning=rec_Sh4_int_IsCpuRunning; 81 | rv->GetRegister=Sh4_int_GetRegister; 82 | rv->SetRegister=Sh4_int_SetRegister; 83 | //rv->RaiseInterrupt=RaiseInterrupt_; 84 | rv->RaiseExeption=rec_sh4_int_RaiseExeption; 85 | rv->ResetCache=rec_sh4_ResetCache; 86 | return rv; 87 | } 88 | 89 | void Release_Sh4If(sh4_if* cpu) 90 | { 91 | free(cpu); 92 | } -------------------------------------------------------------------------------- /nulldc/nullDC/dc/sh4/sh4_interpreter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "types.h" 3 | #include "sh4_if.h" 4 | #include "intc.h" 5 | 6 | #undef sh4op 7 | #define sh4op(str) void __fastcall str (u32 op) 8 | typedef void (__fastcall OpCallFP) (u32 op); 9 | 10 | enum OpcodeType 11 | { 12 | //basic 13 | Normal=0, //heh , nothing special :P 14 | ReadsPC=1, //pc must be set upon calling it 15 | WritesPC=2, //it will write pc (branch) 16 | Delayslot=4, //has a delayslot opcode , valid olny when WritesPC is set 17 | 18 | WritesSR=8, //Writes to SR , and UpdateSR needs to be called 19 | WritesFPSCR=16, //Writes to FPSCR , and UpdateSR needs to be called 20 | 21 | Invalid=128, //invalid 22 | 23 | //heh not basic :P 24 | ReadWritePC=ReadsPC|WritesPC, //Read and writes pc :P 25 | 26 | //branches : 27 | //not delay slot 28 | Branch_dir=ReadWritePC, //direct (eg , pc=r[xx]) -- this one is ReadWritePC b/c the delayslot may use pc ;) 29 | Branch_rel=ReadWritePC, //relative (rg pc+=10); 30 | //delay slot 31 | Branch_dir_d=Delayslot|Branch_dir, //direct (eg , pc=r[xx]) 32 | Branch_rel_d=Delayslot|Branch_rel, //relative (rg pc+=10); 33 | }; 34 | 35 | //interface 36 | void Sh4_int_Run(); 37 | void Sh4_int_Stop(); 38 | void Sh4_int_Step(); 39 | void Sh4_int_Skip(); 40 | void Sh4_int_Reset(bool Manual); 41 | void Sh4_int_Init(); 42 | void Sh4_int_Term(); 43 | bool Sh4_int_IsCpuRunning(); 44 | void __fastcall sh4_int_RaiseExeption(u32 ExeptionCode,u32 VectorAddr); 45 | u32 Sh4_int_GetRegister(Sh4RegType reg); 46 | void Sh4_int_SetRegister(Sh4RegType reg,u32 regdata); 47 | //Other things (mainly used by the cpu core 48 | bool ExecuteDelayslot(); 49 | bool ExecuteDelayslot_RTE(); 50 | int __fastcall UpdateSystem(); 51 | 52 | 53 | -------------------------------------------------------------------------------- /nulldc/nullDC/dc/sh4/sh4_opcode_list.h: -------------------------------------------------------------------------------- 1 | /* 2 | sh4 base core 3 | most of it is (very) old 4 | could use many cleanups, lets hope someone does them 5 | */ 6 | 7 | #pragma once 8 | #include "types.h" 9 | #include "sh4_interpreter.h" 10 | 11 | class BasicBlock; 12 | typedef void (__fastcall RecOpCallFP) (u32 op,u32 pc,BasicBlock* bb); 13 | 14 | extern OpCallFP* OpPtr[0x10000]; 15 | extern RecOpCallFP* RecOpPtr[0x10000]; 16 | extern OpcodeType OpTyp[0x10000]; 17 | 18 | typedef void OpDissasmFP(char* out,const char* const FormatString,u32 pc,u16 opcode); 19 | 20 | enum sh4_eu 21 | { 22 | MT, 23 | EX, 24 | BR, 25 | LS, 26 | FE, 27 | CO, 28 | MA, 29 | sh4_eu_max 30 | }; 31 | 32 | //exception fixup needed , added it to fix exception on opcodes that modify before exept :) 33 | enum sh4_exept_fixup 34 | { 35 | fix_none, 36 | rn_opt_1, //1 if n!=m 37 | rn_opt_2, //2 if n!=m 38 | rn_opt_4, //4 if n!=m 39 | rn_4, //always 4 from rn 40 | rn_fpu_4, //4 or 8 , according to fpu size 41 | }; 42 | struct sh4_opcodelistentry 43 | { 44 | RecOpCallFP* rec_oph; 45 | OpCallFP* oph; 46 | u32 mask; 47 | u32 rez; 48 | OpcodeType type; 49 | OpDissasmFP* dissasm; 50 | char disasm1[64]; 51 | u8 IssueCycles; 52 | u8 LatencyCycles; 53 | sh4_eu unit; 54 | sh4_exept_fixup ex_fixup; 55 | void Dissasemble(char* strout,u32 pc , u16 params) const 56 | { 57 | dissasm(strout,&disasm1[0],pc,params); 58 | } 59 | 60 | INLINE bool SetPC() const 61 | { 62 | return (type & WritesPC)!=0; 63 | } 64 | 65 | INLINE bool NeedPC() const 66 | { 67 | return (type & ReadsPC)!=0; 68 | } 69 | 70 | INLINE bool SetSR() const 71 | { 72 | return (type & WritesSR)!=0; 73 | } 74 | 75 | INLINE bool SetFPSCR() const 76 | { 77 | return (type & WritesFPSCR)!=0; 78 | } 79 | 80 | }; 81 | 82 | extern sh4_opcodelistentry* OpDesc[0x10000]; 83 | #define ExecuteOpcode(op) {OpPtr[op](op);} 84 | 85 | void BuildOpcodeTables(); 86 | void DissasembleOpcode(u16 opcode,u32 pc,char* Dissasm); -------------------------------------------------------------------------------- /nulldc/nullDC/dc/sh4/sh4_registers.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "types.h" 3 | #include "sh4_if.h" 4 | 5 | union mac_type 6 | { 7 | struct { u32 l,h; }; 8 | u64 full; 9 | }; 10 | 11 | __declspec(align(32)) extern f32 sin_table[0x10000+0x4000]; 12 | 13 | struct Sh4RegContext 14 | { 15 | u32 r[16]; 16 | u32 r_bank[8]; 17 | 18 | u32 gbr,ssr,spc,sgr,dbr,vbr; 19 | u32 pr,fpul; 20 | mac_type mac; 21 | u32 pc; 22 | //u16* pc_ptr; 23 | 24 | StatusReg sr; 25 | 26 | fpscr_type fpscr; 27 | 28 | f32 xf[16]; 29 | f32 fr[16]; 30 | 31 | StatusReg old_sr; 32 | fpscr_type old_fpscr; 33 | }; 34 | void GenerateSinCos(); 35 | void CleanupSinCos(); 36 | __declspec(align(64)) extern u32 r[16]; 37 | __declspec(align(64)) extern u32 r_bank[8]; 38 | 39 | extern u32 gbr,ssr,spc,sgr,dbr,vbr; 40 | extern u32 pr,fpul; 41 | extern mac_type mac; 42 | extern u32 pc; 43 | 44 | extern StatusReg sr; 45 | 46 | extern fpscr_type fpscr; 47 | 48 | extern __declspec(align(64)) f32 xf[16]; 49 | extern __declspec(align(64)) f32 fr[16]; 50 | 51 | 52 | extern u32* xf_hex,*fr_hex; 53 | 54 | void SaveSh4Regs(Sh4RegContext* to); 55 | void LoadSh4Regs(Sh4RegContext* from); 56 | 57 | void UpdateFPSCR(); 58 | bool UpdateSR(); 59 | 60 | #ifndef DEBUG 61 | INLINE f64 GetDR(u32 n) 62 | { 63 | #ifdef TRACE 64 | if (n>7) 65 | log("DR_r INDEX OVERRUN %d >7",n); 66 | #endif 67 | double t; 68 | ((u32*)(&t))[1]=fr_hex[(n<<1) | 0]; 69 | ((u32*)(&t))[0]=fr_hex[(n<<1) | 1]; 70 | return t; 71 | } 72 | 73 | INLINE f64 GetXD(u32 n) 74 | { 75 | #ifdef TRACE 76 | if (n>7) 77 | log("XD_r INDEX OVERRUN %d >7",n); 78 | #endif 79 | double t; 80 | ((u32*)(&t))[1]=xf_hex[(n<<1) | 0]; 81 | ((u32*)(&t))[0]=xf_hex[(n<<1) | 1]; 82 | return t; 83 | } 84 | 85 | INLINE void SetDR(u32 n,f64 val) 86 | { 87 | #ifdef TRACE 88 | if (n>7) 89 | log("DR_w INDEX OVERRUN %d >7",n); 90 | #endif 91 | fr_hex[(n<<1) | 1]=((u32*)(&val))[0]; 92 | fr_hex[(n<<1) | 0]=((u32*)(&val))[1]; 93 | } 94 | 95 | INLINE void SetXD(u32 n,f64 val) 96 | { 97 | #ifdef TRACE 98 | if (n>7) 99 | log("XD_w INDEX OVERRUN %d >7",n); 100 | #endif 101 | 102 | xf_hex[(n<<1) | 1]=((u32*)(&val))[0]; 103 | xf_hex[(n<<1) | 0]=((u32*)(&val))[1]; 104 | } 105 | #else 106 | f64 GetDR(u32 n); 107 | f64 GetXD(u32 n); 108 | void SetDR(u32 n,f64 val); 109 | void SetXD(u32 n,f64 val); 110 | #endif 111 | 112 | extern StatusReg old_sr; 113 | extern fpscr_type old_fpscr; 114 | 115 | u32* Sh4_int_GetRegisterPtr(Sh4RegType reg); 116 | void SetFloatStatusReg(); -------------------------------------------------------------------------------- /nulldc/nullDC/dc/sh4/shil/compiler/shil_compiler_base.h: -------------------------------------------------------------------------------- 1 | #include "types.h" 2 | #include "dc\sh4\shil\shil.h" 3 | #include "emitter\emitter.h" 4 | #include "emitter\regalloc\x86_sseregalloc.h" 5 | 6 | extern u32 T_jcond_value; 7 | extern u32 reg_pc_temp_value; 8 | 9 | void shil_compiler_init(x86_block* block,IntegerRegAllocator* ira,FloatRegAllocator* fra); 10 | void shil_compile(shil_opcode* op); 11 | 12 | struct roml_patch 13 | { 14 | x86_Label* p4_access; 15 | u8 resume_offset; 16 | x86_Label* exit_point; 17 | u32 asz; 18 | u32 type; 19 | 20 | x86_reg reg_addr; 21 | x86_reg reg_data; 22 | bool is_float; 23 | }; 24 | 25 | extern vector roml_patch_list; 26 | void apply_roml_patches(); -------------------------------------------------------------------------------- /nulldc/nullDC/dc/sh4/shil/shil_ce.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "types.h" 3 | #include "dc\sh4\sh4_if.h" 4 | #include "dc\sh4\sh4_if.h" 5 | #include "dc\sh4\rec_v1\BasicBlock.h" 6 | 7 | struct shil_ce_info_entry 8 | { 9 | bool is_const; 10 | bool can_be_const; 11 | u32 value; 12 | }; 13 | struct shil_ce_info 14 | { 15 | shil_ce_info_entry reginfo[sh4_reg_count]; 16 | void Init() 17 | { 18 | memset(reginfo,0,sizeof(reginfo)); 19 | for (u32 i=0;ireginfo[i].can_be_const) 27 | { 28 | if (other->reginfo[i].is_const) 29 | { 30 | if (reginfo[i].is_const) 31 | { 32 | if (reginfo[i].value!=other->reginfo[i].value) 33 | { 34 | reginfo[i].is_const=false; 35 | reginfo[i].can_be_const=false; 36 | } 37 | } 38 | else 39 | { 40 | reginfo[i].is_const=true; 41 | reginfo[i].value=other->reginfo[i].value; 42 | } 43 | } 44 | else 45 | { 46 | if (reginfo[i].is_const) 47 | { 48 | reginfo[i].is_const=false; 49 | reginfo[i].can_be_const=false; 50 | } 51 | } 52 | } 53 | else 54 | { 55 | reginfo[i].can_be_const=false; 56 | } 57 | } 58 | } 59 | }; 60 | 61 | void shil_optimise_pass_ce_driver(BasicBlock* bb); -------------------------------------------------------------------------------- /nulldc/nullDC/dc/sh4/tmu.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types.h" 4 | 5 | void UpdateTMU(u32 Cycles); 6 | void tmu_Init(); 7 | void tmu_Reset(bool Manual); 8 | void tmu_Term(); 9 | -------------------------------------------------------------------------------- /nulldc/nullDC/dc/sh4/ubc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types.h" 4 | 5 | //Init/Res/Term 6 | void ubc_Init(); 7 | void ubc_Reset(bool Manual); 8 | void ubc_Term(); 9 | 10 | 11 | //UBC BARA 0xFF200000 0x1F200000 32 Undefined Held Held Held Iclk 12 | extern u32 UBC_BARA; 13 | //UBC BAMRA 0xFF200004 0x1F200004 8 Undefined Held Held Held Iclk 14 | extern u8 UBC_BAMRA; 15 | //UBC BBRA 0xFF200008 0x1F200008 16 0x0000 Held Held Held Iclk 16 | extern u16 UBC_BBRA; 17 | //UBC BARB 0xFF20000C 0x1F20000C 32 Undefined Held Held Held Iclk 18 | extern u32 UBC_BARB; 19 | //UBC BAMRB 0xFF200010 0x1F200010 8 Undefined Held Held Held Iclk 20 | extern u8 UBC_BAMRB; 21 | //UBC BBRB 0xFF200014 0x1F200014 16 0x0000 Held Held Held Iclk 22 | extern u16 UBC_BBRB; 23 | //UBC BDRB 0xFF200018 0x1F200018 32 Undefined Held Held Held Iclk 24 | extern u32 UBC_BDRB; 25 | //UBC BDMRB 0xFF20001C 0x1F20001C 32 Undefined Held Held Held Iclk 26 | extern u32 UBC_BDMRB; 27 | //UBC BRCR 0xFF200020 0x1F200020 16 0x0000 Held Held Held Iclk 28 | extern u16 UBC_BRCR; 29 | -------------------------------------------------------------------------------- /nulldc/nullDC/debug_mem.cpp: -------------------------------------------------------------------------------- 1 | #include "types.h" 2 | 3 | //If the MEM_ALLOC_CHECK define is on , we check for allocation errors 4 | //and report/break 5 | 6 | //Notice for future: 7 | //We can add a check witch mallocs were not freed ect 8 | //What bout calloc and other shit ? 9 | 10 | #ifdef malloc 11 | #undef malloc 12 | #endif 13 | 14 | #ifdef realloc 15 | #undef realloc 16 | #endif 17 | 18 | #ifdef free 19 | #undef free 20 | #endif 21 | 22 | #ifdef MEM_ALLOC_CHECK 23 | void * debug_malloc(size_t size) 24 | { 25 | if (size==0) 26 | { 27 | log("debug_malloc warning : malloc with size=0"); 28 | MEM_ERROR_BREAK; 29 | } 30 | void *rv= malloc(size); 31 | if (rv==0) 32 | { 33 | log("debug_malloc warning : malloc (%d) failed",size); 34 | MEM_ERROR_BREAK; 35 | } 36 | //if (size==1024*128) 37 | // memset(rv,0,size); 38 | //log("malloc %X\n",*(u8*)rv); 39 | 40 | return rv; 41 | } 42 | 43 | void * debug_realloc(void* mem,size_t size) 44 | { 45 | if (size==0) 46 | { 47 | log("debug_realloc warning : malloc with size=0 called \n"); 48 | MEM_ERROR_BREAK; 49 | } 50 | 51 | if (mem==0) 52 | log("debug_realloc warning : malloc with ptr=0 called \n"); 53 | 54 | void *rv= realloc(mem,size); 55 | if (rv==0) 56 | { 57 | log("debug_realloc warning : realloc (0x%p,%d) failed",mem,size); 58 | MEM_ERROR_BREAK; 59 | } 60 | return rv; 61 | } 62 | 63 | void debug_free(void* ptr) 64 | { 65 | if (ptr==0) 66 | { 67 | log("debug_free warning : malloc with ptr==0 called \n"); 68 | MEM_ERROR_BREAK; 69 | } 70 | 71 | free(ptr); 72 | } 73 | #endif -------------------------------------------------------------------------------- /nulldc/nullDC/emitter/BaseTypes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | typedef signed __int8 int8; 3 | typedef signed __int16 int16; 4 | typedef signed __int32 int32; 5 | typedef signed __int64 int64; 6 | typedef unsigned __int8 uint8; 7 | typedef unsigned __int16 uint16; 8 | typedef unsigned __int32 uint32; 9 | typedef unsigned __int64 uint64; 10 | typedef unsigned char uchar; 11 | typedef signed char schar; -------------------------------------------------------------------------------- /nulldc/nullDC/emitter/emitter.cpp: -------------------------------------------------------------------------------- 1 | #include "types.h" 2 | #include "emitter.h" 3 | #include "windows.h" 4 | 5 | x86_features x86_caps; 6 | 7 | #ifndef EXCEPTION_EXECUTE_HANDLER 8 | #define EXCEPTION_EXECUTE_HANDLER 1 9 | #endif 10 | 11 | void x86_features::detect() 12 | { 13 | sse_1=true; 14 | sse_2=true; 15 | sse_3=true; 16 | ssse_3=true; 17 | mmx=true; 18 | 19 | __try 20 | { 21 | __asm addps xmm0,xmm0 22 | } 23 | __except(EXCEPTION_EXECUTE_HANDLER) 24 | { 25 | sse_1=false; 26 | } 27 | 28 | __try 29 | { 30 | __asm addpd xmm0,xmm0 31 | } 32 | __except(EXCEPTION_EXECUTE_HANDLER) 33 | { 34 | sse_2=false; 35 | } 36 | 37 | __try 38 | { 39 | __asm addsubpd xmm0,xmm0 40 | } 41 | __except(EXCEPTION_EXECUTE_HANDLER) 42 | { 43 | sse_3=false; 44 | } 45 | 46 | __try 47 | { 48 | __asm phaddw xmm0,xmm0 49 | } 50 | __except(EXCEPTION_EXECUTE_HANDLER) 51 | { 52 | ssse_3=false; 53 | } 54 | 55 | 56 | __try 57 | { 58 | __asm paddd mm0,mm1 59 | } 60 | __except(EXCEPTION_EXECUTE_HANDLER) 61 | { 62 | mmx=false; 63 | } 64 | 65 | 66 | 67 | 68 | wchar* command_line = GetCommandLine(); 69 | 70 | if (ssse_3 && wcsstr(command_line,L"-nossse3")) 71 | { 72 | log("sSSE3 detected but disabled[-nossse3]\n"); 73 | ssse_3=false; 74 | } 75 | if (sse_3 && wcsstr(command_line,L"-nosse3")) 76 | { 77 | log("SSE3 detected but disabled[-nosse3]\n"); 78 | sse_3=false; 79 | } 80 | 81 | if (sse_2 && wcsstr(command_line,L"-nosse2")) 82 | { 83 | log("SSE2 detected but disabled[-nosse2]\n"); 84 | sse_2=false; 85 | } 86 | 87 | if (sse_1 && wcsstr(command_line,L"-nosse1")) 88 | { 89 | log("SSE1 detected but disabled[-nosse1]\n"); 90 | sse_1=false; 91 | } 92 | 93 | if (mmx && wcsstr(command_line,L"-nommx")) 94 | { 95 | log("MMX detected but disabled[-nommx]\n"); 96 | mmx=false; 97 | } 98 | 99 | 100 | log("Detected cpu features : "); 101 | if (mmx) 102 | log("MMX "); 103 | if (sse_1) 104 | log("SSE1 "); 105 | if (sse_2) 106 | log("SSE2 "); 107 | if (sse_3) 108 | log("SSE3 "); 109 | if (ssse_3) 110 | log("sSSE3[ohh god , is that a name?] "); 111 | 112 | log("\n"); 113 | log("\n"); 114 | 115 | __try 116 | { 117 | __asm sfence; 118 | } 119 | __except(EXCEPTION_EXECUTE_HANDLER) 120 | { 121 | //Blah 122 | } 123 | 124 | __try 125 | { 126 | __asm emms; 127 | } 128 | __except(EXCEPTION_EXECUTE_HANDLER) 129 | { 130 | //Blah 131 | } 132 | } -------------------------------------------------------------------------------- /nulldc/nullDC/emitter/emitter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "x86_emitter.h" 3 | 4 | struct x86_features 5 | { 6 | void detect(); 7 | bool sse_1; 8 | bool sse_2; 9 | bool sse_3; 10 | bool ssse_3; 11 | bool mmx; 12 | }; 13 | 14 | extern x86_features x86_caps; -------------------------------------------------------------------------------- /nulldc/nullDC/emitter/regalloc/regalloc_base.h: -------------------------------------------------------------------------------- 1 | public: 2 | -------------------------------------------------------------------------------- /nulldc/nullDC/emitter/regalloc/x86_intregalloc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "regalloc.h" -------------------------------------------------------------------------------- /nulldc/nullDC/emitter/regalloc/x86_sseregalloc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "regalloc.h" 3 | -------------------------------------------------------------------------------- /nulldc/nullDC/gui/base.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "types.h" 3 | #include "dc/sh4/sh4_if.h" 4 | #include "plugins/plugin_manager.h" 5 | 6 | bool CreateGUI(); 7 | void DestroyGUI(); 8 | void GuiLoop(); 9 | 10 | void* EXPORT_CALL GetRenderTargetHandle(); 11 | bool SelectPluginsGui(); 12 | 13 | //void EXPORT_CALL DeleteAllMenuItemChilds(u32 id); 14 | void SetMenuItemHandler(u32 id,MenuItemSelectedFP* h); 15 | /* 16 | u32 EXPORT_CALL AddMenuItem(u32 parent,s32 pos,char* text,MenuItemSelectedFP* handler ,u32 checked); 17 | void EXPORT_CALL SetMenuItemStyle(u32 id,u32 style,u32 mask); 18 | void EXPORT_CALL GetMenuItem(u32 id,MenuItem* info,u32 mask); 19 | void EXPORT_CALL SetMenuItem(u32 id,MenuItem* info,u32 mask); 20 | void EXPORT_CALL DeleteMenuItem(u32 id); 21 | //These still exist , but are no longer given to plugins 22 | 23 | void EXPORT_CALL SetMenuItemBitmap(u32 id,void* hbmp); 24 | u32 EXPORT_CALL GetMenuItemStyle(u32 id); 25 | void* EXPORT_CALL GetMenuItemBitmap(u32 id); 26 | */ 27 | extern MenuIDList MenuIDs; 28 | -------------------------------------------------------------------------------- /nulldc/nullDC/gui/ndc_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skmp/nullDC-v1/1611c3cf0aa2755611455aa7a02b4f62babee7bd/nulldc/nullDC/gui/ndc_icon.ico -------------------------------------------------------------------------------- /nulldc/nullDC/gui/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by resource.rc 4 | // 5 | #define IDI_ICON1 122 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 123 12 | #define _APS_NEXT_COMMAND_VALUE 40044 13 | #define _APS_NEXT_CONTROL_VALUE 1119 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /nulldc/nullDC/gui/resource.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #include "windows.h" 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | #undef APSTUDIO_READONLY_SYMBOLS 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // Neutral resources 17 | 18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) 19 | #ifdef _WIN32 20 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 21 | #pragma code_page(1253) 22 | #endif //_WIN32 23 | 24 | ///////////////////////////////////////////////////////////////////////////// 25 | // 26 | // Icon 27 | // 28 | 29 | // Icon with lowest ID value placed first to ensure application icon 30 | // remains consistent on all systems. 31 | IDI_ICON1 ICON "ndc_icon.ico" 32 | #endif // Neutral resources 33 | ///////////////////////////////////////////////////////////////////////////// 34 | 35 | 36 | ///////////////////////////////////////////////////////////////////////////// 37 | // Greek resources 38 | 39 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ELL) 40 | #ifdef _WIN32 41 | LANGUAGE LANG_GREEK, SUBLANG_DEFAULT 42 | #pragma code_page(1253) 43 | #endif //_WIN32 44 | 45 | #ifdef APSTUDIO_INVOKED 46 | ///////////////////////////////////////////////////////////////////////////// 47 | // 48 | // TEXTINCLUDE 49 | // 50 | 51 | 1 TEXTINCLUDE 52 | BEGIN 53 | "resource.h\0" 54 | END 55 | 56 | 2 TEXTINCLUDE 57 | BEGIN 58 | "#include ""afxres.h""\r\n" 59 | "\0" 60 | END 61 | 62 | 3 TEXTINCLUDE 63 | BEGIN 64 | "\r\n" 65 | "\0" 66 | END 67 | 68 | #endif // APSTUDIO_INVOKED 69 | 70 | #endif // Greek resources 71 | ///////////////////////////////////////////////////////////////////////////// 72 | 73 | 74 | 75 | #ifndef APSTUDIO_INVOKED 76 | ///////////////////////////////////////////////////////////////////////////// 77 | // 78 | // Generated from the TEXTINCLUDE 3 resource. 79 | // 80 | 81 | 82 | ///////////////////////////////////////////////////////////////////////////// 83 | #endif // not APSTUDIO_INVOKED 84 | 85 | -------------------------------------------------------------------------------- /nulldc/nullDC/log/logging.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "../types.h" 6 | 7 | enum ELogMode 8 | { 9 | LOG_MODE_DEFAULT = 0, //Dump to console 10 | LOG_MODE_STREAM, //Dump to file 11 | LOG_MODE_COMBINE, //Dump to file + dump to console 12 | LOG_MODE_SILENT, //Do nothing 13 | }; 14 | 15 | static const char* SLogMode[] = 16 | { 17 | "LOG_MODE_DEFAULT", 18 | "LOG_MODE_STREAM", 19 | "LOG_MODE_COMBINE", 20 | "LOG_MODE_SILENT", 21 | }; 22 | 23 | class CLogger 24 | { 25 | private://Ptrs 26 | char* mBuf0; 27 | char* mBuf1; 28 | 29 | private://Consts/Enums 30 | ELogMode mMode; 31 | 32 | private://Classes 33 | std::ofstream* mFile; 34 | 35 | private://Flags 36 | bool mFirstRun; 37 | bool mDisplayFilenameOnly; 38 | 39 | private://Funcs 40 | void invalidateStream(); 41 | 42 | public://C:D-tors 43 | CLogger(); 44 | ~CLogger(); 45 | 46 | public://Setters 47 | void setMode(const ELogMode mode,const char* arg0 = 0); 48 | void setFilenameOnly(const bool filenameOnly); 49 | 50 | public://Utils 51 | void dump(const char* field,const char* function,const char* sourceFile,const u32 line,const char* format,...); 52 | 53 | public://Getters 54 | inline const ELogMode getMode() const { return mMode; } 55 | inline const char* getModeString() const { return *(SLogMode + mMode); } 56 | }; 57 | 58 | CLogger* getActiveLogger(); 59 | -------------------------------------------------------------------------------- /nulldc/nullDC/log/logging_interface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #define DEFAULT_LOGGING 3 | 4 | #ifdef DEFAULT_LOGGING 5 | #define logSetMode(_newMode_) 6 | #define logSetModeEx(_newMode_,_arg0_) 7 | #define log(_fmt_,...) //printf(_fmt_,__VA_ARGS__) 8 | #define logEx(_field_,_fmt_,...) 9 | #else 10 | #include "logging.h" 11 | #define logSetMode(_newMode_) getActiveLogger()->setMode(_newMode_,0) 12 | #define logSetModeEx(_newMode_,_arg0_) getActiveLogger()->setMode(_newMode_,_arg0_) 13 | #define log(_fmt_,...) getActiveLogger()->dump(0,__FUNCTION__,__FILE__,__LINE__,_fmt_,__VA_ARGS__) 14 | #define logEx(_field_,_fmt_,...) getActiveLogger()->dump(_field_,__FUNCTION__,__FILE__,__LINE__,_fmt_,__VA_ARGS__) 15 | #endif 16 | -------------------------------------------------------------------------------- /nulldc/nullDC/naomi/naomi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** naomi.h 3 | */ 4 | 5 | #pragma once 6 | #if defined(BUILD_NAOMI ) || defined(BUILD_ATOMISWAVE) 7 | 8 | 9 | 10 | void naomi_reg_Init(); 11 | void naomi_reg_Term(); 12 | void naomi_reg_Reset(bool Manual); 13 | 14 | void Update_naomi(); 15 | 16 | u32 ReadMem_naomi(u32 Addr, u32 sz); 17 | void WriteMem_naomi(u32 Addr, u32 data, u32 sz); 18 | 19 | void NaomiBoardIDWrite(const u16 Data); 20 | void NaomiBoardIDWriteControl(const u16 Data); 21 | u16 NaomiBoardIDRead(); 22 | bool NaomiSelectFile(void* handle); 23 | #endif 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /nulldc/nullDC/naomi/naomi_regs.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** naomi_regs.h 3 | */ 4 | 5 | #pragma once 6 | #if defined(BUILD_NAOMI ) || defined(BUILD_ATOMISWAVE) 7 | 8 | 9 | 10 | 11 | enum 12 | { 13 | NAOMI_ROM_OFFSETH_addr = 0x5f7000, 14 | NAOMI_ROM_OFFSETL_addr = 0x5f7004, 15 | NAOMI_ROM_DATA_addr = 0x5f7008, 16 | NAOMI_DMA_OFFSETH_addr = 0x5f700C, 17 | NAOMI_DMA_OFFSETL_addr = 0x5f7010, 18 | NAOMI_DMA_COUNT_addr = 0x5f7014, 19 | NAOMI_BOARDID_WRITE_addr = 0x5F7078, 20 | NAOMI_BOARDID_READ_addr = 0x5F707C, 21 | NAOMI_COMM_OFFSET_addr = 0x5F7050, 22 | NAOMI_COMM_DATA_addr = 0x5F7054, 23 | }; 24 | 25 | 26 | 27 | extern u32 NAOMI_ROM_OFFSETH; 28 | extern u32 NAOMI_ROM_OFFSETL; 29 | extern u32 NAOMI_ROM_DATA; 30 | extern u32 NAOMI_DMA_OFFSETH; 31 | extern u32 NAOMI_DMA_OFFSETL; 32 | extern u32 NAOMI_DMA_COUNT; 33 | extern u32 NAOMI_BOARDID_WRITE; 34 | extern u32 NAOMI_BOARDID_READ; 35 | extern u32 NAOMI_COMM_OFFSET; 36 | extern u32 NAOMI_COMM_DATA; 37 | 38 | 39 | 40 | #endif -------------------------------------------------------------------------------- /nulldc/nullDC/plugins/plugin_manager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "types.h" 3 | #include "gui_plugin_header.h" 4 | #include "dc/sh4/sh4_if.h" 5 | 6 | //Plugin handling functions :) 7 | struct nullDC_plugin 8 | { 9 | nullDC_plugin() 10 | { 11 | Inited=false; 12 | Loaded=false; 13 | } 14 | cDllHandler dll; 15 | int id; 16 | wchar dll_file[512]; 17 | s32 Open(wchar* plugin); 18 | virtual void LoadI(plugin_interface* plugin)=0; 19 | bool IsOpened(); 20 | void Close(); 21 | bool Inited; 22 | bool Loaded; 23 | }; 24 | struct nullDC_PowerVR_plugin:common_info,pvr_plugin_if,nullDC_plugin 25 | { 26 | void LoadI(plugin_interface* plugin); 27 | }; 28 | 29 | struct nullDC_GDRom_plugin:common_info,gdr_plugin_if,nullDC_plugin 30 | { 31 | void LoadI(plugin_interface* plugin); 32 | }; 33 | 34 | struct nullDC_AICA_plugin:common_info,aica_plugin_if,nullDC_plugin 35 | { 36 | void LoadI(plugin_interface* plugin); 37 | }; 38 | struct nullDC_ARM_plugin:common_info,arm_plugin_if,nullDC_plugin 39 | { 40 | void LoadI(plugin_interface* plugin); 41 | }; 42 | 43 | struct nullDC_Maple_plugin:common_info,maple_plugin_if,nullDC_plugin 44 | { 45 | u32 ReferenceCount; 46 | void LoadI(plugin_interface* plugin); 47 | }; 48 | 49 | struct nullDC_ExtDevice_plugin:common_info,ext_device_plugin_if,nullDC_plugin 50 | { 51 | void LoadI(plugin_interface* plugin); 52 | }; 53 | //Struct to hold plugin info 54 | struct PluginLoadInfo 55 | { 56 | wchar Name[128]; //plugin name 57 | PluginType Type; //plugin type 58 | wchar dll[512]; 59 | }; 60 | struct MapleDeviceDefinition:maple_device_definition 61 | { 62 | wchar dll[512]; //xxxx.dll:id 63 | wchar dll_file[512]; //xxxx.dll 64 | u32 id; 65 | }; 66 | 67 | void EnumeratePlugins(); 68 | vector* GetPluginList(PluginType type); 69 | vector* GetMapleDeviceList(MapleDeviceType type); 70 | 71 | //This is not used for maple 72 | 73 | extern sh4_if* sh4_cpu; 74 | //Currently used plugins 75 | extern nullDC_PowerVR_plugin libPvr; 76 | extern nullDC_GDRom_plugin libGDR; 77 | extern nullDC_AICA_plugin libAICA; 78 | extern nullDC_ARM_plugin libARM; 79 | extern vectorlibMaple; 80 | extern nullDC_ExtDevice_plugin libExtDevice; 81 | extern gui_plugin_info libgui; 82 | //more to come 83 | 84 | bool plugins_Load(); 85 | void plugins_Unload(); 86 | bool plugins_Select(); 87 | void plugins_Reset(bool Manual); 88 | 89 | //sh4 thread 90 | bool plugins_Init(); 91 | void plugins_Term(); 92 | 93 | void EXPORT_CALL BroadcastEvent(u32 target,u32 eid,void* pdata,u32 ldata); -------------------------------------------------------------------------------- /nulldc/nullDC/plugins/plugin_types.cpp: -------------------------------------------------------------------------------- 1 | #include "plugin_header.h" -------------------------------------------------------------------------------- /nulldc/nullDC/serial_ipc/serial_ipc_client.h: -------------------------------------------------------------------------------- 1 | #include "types.h" 2 | 3 | int serial_cmdl(wchar** arg,int cl); 4 | int slave_cmdl(wchar** arg,int cl); 5 | //void PrintSerialIPUsage(int argc, char *argv[]); 6 | void WriteSerial(u8 data); 7 | bool PendingSerialData(); 8 | s32 ReadSerial(); 9 | float GetRxSpeed(); 10 | float GetTxSpeed(); 11 | //this is a fake dma handler 12 | //to initiate it write size to 0 13 | //pointer to 4 14 | //0xdeadc0de to 8 15 | void WriteBlockSerial(u8* blk,u32 size,u8* sum); -------------------------------------------------------------------------------- /nulldc/nullDC/timing/timer.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _timer_hpp_ 2 | #define _timer_hpp_ 3 | 4 | #include "../basic_types.h" 5 | #include 6 | 7 | class timer_if { 8 | public: 9 | 10 | timer_if() { 11 | } 12 | 13 | ~timer_if() { 14 | } 15 | 16 | virtual u64 ticks() { 17 | return 0U; 18 | } 19 | 20 | virtual u64 ticks_qp() { 21 | return 0U; 22 | } 23 | 24 | virtual f64 seconds() { 25 | return 0.0; 26 | } 27 | 28 | private: 29 | }; 30 | 31 | class basic_timer_c: public timer_if { 32 | public: 33 | 34 | basic_timer_c() { 35 | } 36 | 37 | ~basic_timer_c() { 38 | } 39 | 40 | u64 ticks() { 41 | return timeGetTime(); 42 | } 43 | 44 | u64 ticks_qp() { 45 | return timeGetTime(); 46 | } 47 | 48 | f64 seconds() { 49 | const u64 r = this->ticks(); 50 | return (0U == r) ? 0.0 : r / 1000.0; 51 | } 52 | 53 | private: 54 | }; 55 | 56 | class cpu_timer_c: public timer_if { 57 | public: 58 | 59 | cpu_timer_c() { 60 | } 61 | 62 | ~cpu_timer_c() { 63 | } 64 | 65 | u64 ticks() { 66 | return __rdtsc(); 67 | } 68 | 69 | u64 ticks_qp() { 70 | return __rdtsc(); 71 | } 72 | 73 | f64 seconds() { 74 | const u64 r = this->ticks(); 75 | return (0U == r) ? 0.0 : r / 1000.0; 76 | } 77 | 78 | private: 79 | }; 80 | 81 | class high_frequency_timer_c: public timer_if { 82 | public: 83 | 84 | high_frequency_timer_c() { 85 | this->init(); 86 | } 87 | 88 | ~high_frequency_timer_c() { 89 | } 90 | 91 | u64 ticks() { 92 | u64 r; 93 | if (!m_b_high_frq) { 94 | return GetTickCount(); 95 | } 96 | 97 | QueryPerformanceCounter(&m_time_now); 98 | r = (m_time_now.QuadPart * 1000ULL); 99 | return (r != 0U) ? r / m_frq.QuadPart : 0U; 100 | } 101 | 102 | u64 ticks_qp() { 103 | if (!m_b_high_frq) { 104 | return GetTickCount(); 105 | } 106 | 107 | QueryPerformanceCounter(&m_time_now); 108 | return m_time_now.QuadPart; 109 | } 110 | 111 | f64 seconds() { 112 | const u64 r = this->ticks(); 113 | return (0U == r) ? 0.0 : r / 1000.0; 114 | } 115 | 116 | private: 117 | inline void init() { 118 | m_b_high_frq = QueryPerformanceFrequency(&m_frq); 119 | } 120 | 121 | BOOL m_b_high_frq; 122 | LARGE_INTEGER m_frq; 123 | LARGE_INTEGER m_time_now; 124 | }; 125 | 126 | #endif 127 | -------------------------------------------------------------------------------- /nulldc/plugins/EmptyAICA/EmptyAICA.cpp: -------------------------------------------------------------------------------- 1 | // nullAICA.cpp : Defines the entry point for the DLL application. 2 | // 3 | 4 | #include "EmptyAICA.h" 5 | #include "aica_hax.h" 6 | #include "aica_hle.h" 7 | 8 | 9 | BOOL APIENTRY DllMain( HMODULE hModule, 10 | DWORD ul_reason_for_call, 11 | LPVOID lpReserved 12 | ) 13 | { 14 | return TRUE; 15 | } 16 | 17 | 18 | void cfgdlg(PluginType type,void* window) 19 | { 20 | //printf("null AICA plugin [h4x0rs olny kthx]:No config kthx , however i will show ya some hle info :D\n"); 21 | //MessageBox((HWND)window,"Nothing to configure","nullAICA plugin",MB_OK | MB_ICONINFORMATION); 22 | //ARM_Katana_Driver_Info(); 23 | } 24 | 25 | s32 FASTCALL PluginLoad(emu_info* param) 26 | { 27 | return rv_ok; 28 | } 29 | 30 | void FASTCALL PluginUnload() 31 | { 32 | } 33 | s32 FASTCALL Init(aica_init_params* param) 34 | { 35 | aica_ram=param->aica_ram; 36 | init_mem(); 37 | InitHLE(); 38 | 39 | return rv_ok; 40 | } 41 | void FASTCALL Term() 42 | { 43 | term_mem(); 44 | TermHLE(); 45 | } 46 | void FASTCALL Reset(bool Manual) 47 | { 48 | ResetHLE(); 49 | } 50 | 51 | //Give to the emu pointers for the PowerVR interface 52 | void EXPORT_CALL dcGetInterface(plugin_interface* info) 53 | { 54 | #define c info->common 55 | #define a info->aica 56 | 57 | info->InterfaceVersion=PLUGIN_I_F_VERSION; 58 | 59 | wcscpy(c.Name,L"Empty Aica Plugin [no sound/reduced compat] [" _T(__DATE__) L"]"); 60 | 61 | c.InterfaceVersion=AICA_PLUGIN_I_F_VERSION; 62 | c.Type=Plugin_AICA; 63 | 64 | c.Load=PluginLoad; 65 | c.Unload=PluginUnload; 66 | 67 | a.Init=Init; 68 | a.Reset=Reset; 69 | a.Term=Term; 70 | 71 | a.Update=UpdateAICA; 72 | 73 | a.ReadMem_aica_reg=ReadMem_reg; 74 | a.WriteMem_aica_reg=WriteMem_reg; 75 | 76 | /* 77 | info->Init=dcInit; 78 | info->Term=dcTerm; 79 | info->Reset=dcReset; 80 | 81 | info->ThreadInit=dcThreadInit; 82 | info->ThreadTerm=dcThreadTerm; 83 | info->ShowConfig=cfgdlg; 84 | info->Type=PluginType::AICA; 85 | 86 | info->InterfaceVersion.full=AICA_PLUGIN_I_F_VERSION; 87 | 88 | info->ReadMem_aica_ram=ReadMem_ram; 89 | info->WriteMem_aica_ram=WriteMem_ram; 90 | info->ReadMem_aica_reg=ReadMem_reg; 91 | info->WriteMem_aica_reg=WriteMem_reg; 92 | info->UpdateAICA=UpdateAICA;*/ 93 | } -------------------------------------------------------------------------------- /nulldc/plugins/EmptyAICA/EmptyAICA.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //bleh stupid windoze header 3 | #include "nullDC\plugins\plugin_header.h" 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #define BUILD 0 11 | #define MINOR 0 12 | #define MAJOR 0 13 | 14 | #define DCclock (200*1000*1000) 15 | 16 | //called when plugin is used by emu (you should do first time init here) 17 | void dcInit(void* param,PluginType type); 18 | 19 | //called when plugin is unloaded by emu , olny if dcInit is called (eg , not called to enumerate plugins) 20 | void dcTerm(PluginType type); 21 | 22 | //It's suposed to reset anything 23 | void dcReset(bool Manual,PluginType type); 24 | 25 | //called when entering sh4 thread , from the new thread context (for any thread speciacific init) 26 | void dcThreadInit(PluginType type); 27 | 28 | //called when exiting from sh4 thread , from the new thread context (for any thread speciacific de init) :P 29 | void dcThreadTerm(PluginType type); 30 | 31 | #define ReadMemArrRet(arr,addr,sz) \ 32 | {if (sz==1) \ 33 | return arr[addr]; \ 34 | else if (sz==2) \ 35 | return *(u16*)&arr[addr]; \ 36 | else if (sz==4) \ 37 | return *(u32*)&arr[addr];} 38 | 39 | #define WriteMemArrRet(arr,addr,data,sz) \ 40 | {if(sz==1) \ 41 | {arr[addr]=(u8)data;return;} \ 42 | else if (sz==2) \ 43 | {*(u16*)&arr[addr]=(u16)data;return;} \ 44 | else if (sz==4) \ 45 | {*(u32*)&arr[addr]=data;return;}} -------------------------------------------------------------------------------- /nulldc/plugins/EmptyAICA/EmptyAICA.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {bdff9e09-a130-4525-bb95-2bbbf8461d35} 10 | 11 | 12 | 13 | 14 | plugin 15 | 16 | 17 | AICA 18 | 19 | 20 | AICA 21 | 22 | 23 | 24 | 25 | plugin 26 | 27 | 28 | AICA 29 | 30 | 31 | AICA 32 | 33 | 34 | 35 | 36 | plugin 37 | 38 | 39 | -------------------------------------------------------------------------------- /nulldc/plugins/EmptyAICA/aica_hax.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "EmptyAICA.h" 3 | 4 | u32 FASTCALL ReadMem_reg(u32 addr,u32 size); 5 | void FASTCALL WriteMem_reg(u32 addr,u32 data,u32 size); 6 | 7 | u32 ReadMem_ram(u32 addr,u32 size); 8 | void WriteMem_ram(u32 addr,u32 data,u32 size); 9 | 10 | void FASTCALL UpdateAICA(u32 Cycles); 11 | 12 | #define AICA_MEM_SIZE (2*1024*1024) 13 | #define AICA_MEM_MASK (AICA_MEM_SIZE-1) 14 | 15 | void init_mem(); 16 | void term_mem(); 17 | 18 | extern u8 *aica_reg; 19 | extern u8 *aica_ram; -------------------------------------------------------------------------------- /nulldc/plugins/EmptyAICA/exports.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | dcGetInterface -------------------------------------------------------------------------------- /nulldc/plugins/ImgReader/ImgReader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //bleh stupid windoze header 3 | #include "nullDC\plugins\plugin_header.h" 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | #define BUILD 0 12 | #define MINOR 0 13 | #define MAJOR 1 14 | extern emu_info emu; 15 | extern wchar emu_name[512]; 16 | #define verify(x) if((x)==false){ printf("Verify Failed : " #x "\n in %s -> %s : %d \n",__FUNCTION__,__FILE__,__LINE__); __debugbreak(); } 17 | struct _setts 18 | { 19 | bool PatchRegion; 20 | bool LoadDefaultImage; 21 | wchar DefaultImage[512]; 22 | wchar LastImage[512]; 23 | }; 24 | 25 | extern _setts settings; 26 | void SaveSettings(); -------------------------------------------------------------------------------- /nulldc/plugins/ImgReader/cdi.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "common.h" 3 | 4 | Disc* cdi_parse(wchar* file); -------------------------------------------------------------------------------- /nulldc/plugins/ImgReader/chd.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "common.h" 3 | 4 | Disc* chd_parse(wchar* file); -------------------------------------------------------------------------------- /nulldc/plugins/ImgReader/deps/coretypes.h: -------------------------------------------------------------------------------- 1 | 2 | #include "ImgReader.h" 3 | typedef u64 UINT64; 4 | typedef u32 UINT32; 5 | typedef u16 UINT16; 6 | typedef u8 UINT8; 7 | 8 | typedef s64 INT64; 9 | typedef s32 INT32; 10 | typedef s16 INT16; 11 | typedef s8 INT8; 12 | 13 | #define INLINE inline 14 | #define core_file FILE 15 | 16 | #define ARRAY_LENGTH(x) (sizeof(x)/sizeof(x[0])) -------------------------------------------------------------------------------- /nulldc/plugins/ImgReader/deps/md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This is the header file for the MD5 message-digest algorithm. 3 | * The algorithm is due to Ron Rivest. This code was 4 | * written by Colin Plumb in 1993, no copyright is claimed. 5 | * This code is in the public domain; do with it what you wish. 6 | * 7 | * Equivalent code is available from RSA Data Security, Inc. 8 | * This code has been tested against that, and is equivalent, 9 | * except that you don't need to include two pages of legalese 10 | * with every copy. 11 | * 12 | * To compute the message digest of a chunk of bytes, declare an 13 | * MD5Context structure, pass it to MD5Init, call MD5Update as 14 | * needed on buffers full of bytes, and then call MD5Final, which 15 | * will fill a supplied 16-byte array with the digest. 16 | * 17 | * Changed so as no longer to depend on Colin Plumb's `usual.h' 18 | * header definitions; now uses stuff from dpkg's config.h 19 | * - Ian Jackson . 20 | * Still in the public domain. 21 | */ 22 | 23 | #ifndef MD5_H 24 | #define MD5_H 25 | 26 | typedef unsigned int UWORD32; 27 | 28 | #define md5byte unsigned char 29 | 30 | struct MD5Context { 31 | UWORD32 buf[4]; 32 | UWORD32 bytes[2]; 33 | UWORD32 in[16]; 34 | }; 35 | 36 | void MD5Init(struct MD5Context *context); 37 | void MD5Update(struct MD5Context *context, md5byte const *buf, unsigned len); 38 | void MD5Final(unsigned char digest[16], struct MD5Context *context); 39 | void MD5Transform(UWORD32 buf[4], UWORD32 const in[16]); 40 | 41 | #endif /* !MD5_H */ 42 | 43 | -------------------------------------------------------------------------------- /nulldc/plugins/ImgReader/deps/sha1.h: -------------------------------------------------------------------------------- 1 | /* sha1.h 2 | * 3 | * The sha1 hash function. 4 | */ 5 | 6 | /* nettle, low-level cryptographics library 7 | * 8 | * Copyright 2001 Niels Moeller 9 | * 10 | * The nettle library is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation; either version 2.1 of the License, or (at your 13 | * option) any later version. 14 | * 15 | * The nettle library is distributed in the hope that it will be useful, but 16 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 18 | * License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public License 21 | * along with the nettle library; see the file COPYING.LIB. If not, write to 22 | * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 23 | * MA 02111-1307, USA. 24 | */ 25 | 26 | #ifndef NETTLE_SHA1_H_INCLUDED 27 | #define NETTLE_SHA1_H_INCLUDED 28 | 29 | #include "coretypes.h" 30 | 31 | 32 | 33 | #define SHA1_DIGEST_SIZE 20 34 | #define SHA1_DATA_SIZE 64 35 | 36 | /* Digest is kept internally as 4 32-bit words. */ 37 | #define _SHA1_DIGEST_LENGTH 5 38 | 39 | struct sha1_ctx 40 | { 41 | UINT32 digest[_SHA1_DIGEST_LENGTH]; /* Message digest */ 42 | UINT32 count_low, count_high; /* 64-bit block count */ 43 | UINT8 block[SHA1_DATA_SIZE]; /* SHA1 data buffer */ 44 | unsigned int index; /* index into buffer */ 45 | }; 46 | 47 | void 48 | sha1_init(struct sha1_ctx *ctx); 49 | 50 | void 51 | sha1_update(struct sha1_ctx *ctx, 52 | unsigned length, 53 | const UINT8 *data); 54 | 55 | void 56 | sha1_final(struct sha1_ctx *ctx); 57 | 58 | void 59 | sha1_digest(const struct sha1_ctx *ctx, 60 | unsigned length, 61 | UINT8 *digest); 62 | 63 | #endif /* NETTLE_SHA1_H_INCLUDED */ 64 | -------------------------------------------------------------------------------- /nulldc/plugins/ImgReader/deps/zlib/compress.c: -------------------------------------------------------------------------------- 1 | /* compress.c -- compress a memory buffer 2 | * Copyright (C) 1995-2003 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Compresses the source buffer into the destination buffer. The level 13 | parameter has the same meaning as in deflateInit. sourceLen is the byte 14 | length of the source buffer. Upon entry, destLen is the total size of the 15 | destination buffer, which must be at least 0.1% larger than sourceLen plus 16 | 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. 17 | 18 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough 19 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, 20 | Z_STREAM_ERROR if the level parameter is invalid. 21 | */ 22 | int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) 23 | Bytef *dest; 24 | uLongf *destLen; 25 | const Bytef *source; 26 | uLong sourceLen; 27 | int level; 28 | { 29 | z_stream stream; 30 | int err; 31 | 32 | stream.next_in = (Bytef*)source; 33 | stream.avail_in = (uInt)sourceLen; 34 | #ifdef MAXSEG_64K 35 | /* Check for source > 64K on 16-bit machine: */ 36 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 37 | #endif 38 | stream.next_out = dest; 39 | stream.avail_out = (uInt)*destLen; 40 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 41 | 42 | stream.zalloc = (alloc_func)0; 43 | stream.zfree = (free_func)0; 44 | stream.opaque = (voidpf)0; 45 | 46 | err = deflateInit(&stream, level); 47 | if (err != Z_OK) return err; 48 | 49 | err = deflate(&stream, Z_FINISH); 50 | if (err != Z_STREAM_END) { 51 | deflateEnd(&stream); 52 | return err == Z_OK ? Z_BUF_ERROR : err; 53 | } 54 | *destLen = stream.total_out; 55 | 56 | err = deflateEnd(&stream); 57 | return err; 58 | } 59 | 60 | /* =========================================================================== 61 | */ 62 | int ZEXPORT compress (dest, destLen, source, sourceLen) 63 | Bytef *dest; 64 | uLongf *destLen; 65 | const Bytef *source; 66 | uLong sourceLen; 67 | { 68 | return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); 69 | } 70 | 71 | /* =========================================================================== 72 | If the default memLevel or windowBits for deflateInit() is changed, then 73 | this function needs to be updated. 74 | */ 75 | uLong ZEXPORT compressBound (sourceLen) 76 | uLong sourceLen; 77 | { 78 | return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11; 79 | } 80 | -------------------------------------------------------------------------------- /nulldc/plugins/ImgReader/deps/zlib/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | void inflate_fast OF((z_streamp strm, unsigned start)); 12 | -------------------------------------------------------------------------------- /nulldc/plugins/ImgReader/deps/zlib/inftrees.h: -------------------------------------------------------------------------------- 1 | /* inftrees.h -- header to use inftrees.c 2 | * Copyright (C) 1995-2005 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* Structure for decoding tables. Each entry provides either the 12 | information needed to do the operation requested by the code that 13 | indexed that table entry, or it provides a pointer to another 14 | table that indexes more bits of the code. op indicates whether 15 | the entry is a pointer to another table, a literal, a length or 16 | distance, an end-of-block, or an invalid code. For a table 17 | pointer, the low four bits of op is the number of index bits of 18 | that table. For a length or distance, the low four bits of op 19 | is the number of extra bits to get after the code. bits is 20 | the number of bits in this code or part of the code to drop off 21 | of the bit buffer. val is the actual byte to output in the case 22 | of a literal, the base length or distance, or the offset from 23 | the current table to the next table. Each entry is four bytes. */ 24 | typedef struct { 25 | unsigned char op; /* operation, extra bits, table bits */ 26 | unsigned char bits; /* bits in this part of the code */ 27 | unsigned short val; /* offset in table or code value */ 28 | } code; 29 | 30 | /* op values as set by inflate_table(): 31 | 00000000 - literal 32 | 0000tttt - table link, tttt != 0 is the number of table index bits 33 | 0001eeee - length or distance, eeee is the number of extra bits 34 | 01100000 - end of block 35 | 01000000 - invalid code 36 | */ 37 | 38 | /* Maximum size of dynamic tree. The maximum found in a long but non- 39 | exhaustive search was 1444 code structures (852 for length/literals 40 | and 592 for distances, the latter actually the result of an 41 | exhaustive search). The true maximum is not known, but the value 42 | below is more than safe. */ 43 | #define ENOUGH 2048 44 | #define MAXD 592 45 | 46 | /* Type of code to build for inftable() */ 47 | typedef enum { 48 | CODES, 49 | LENS, 50 | DISTS 51 | } codetype; 52 | 53 | extern int inflate_table OF((codetype type, unsigned short FAR *lens, 54 | unsigned codes, code FAR * FAR *table, 55 | unsigned FAR *bits, unsigned short FAR *work)); 56 | -------------------------------------------------------------------------------- /nulldc/plugins/ImgReader/deps/zlib/uncompr.c: -------------------------------------------------------------------------------- 1 | /* uncompr.c -- decompress a memory buffer 2 | * Copyright (C) 1995-2003 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Decompresses the source buffer into the destination buffer. sourceLen is 13 | the byte length of the source buffer. Upon entry, destLen is the total 14 | size of the destination buffer, which must be large enough to hold the 15 | entire uncompressed data. (The size of the uncompressed data must have 16 | been saved previously by the compressor and transmitted to the decompressor 17 | by some mechanism outside the scope of this compression library.) 18 | Upon exit, destLen is the actual size of the compressed buffer. 19 | This function can be used to decompress a whole file at once if the 20 | input file is mmap'ed. 21 | 22 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not 23 | enough memory, Z_BUF_ERROR if there was not enough room in the output 24 | buffer, or Z_DATA_ERROR if the input data was corrupted. 25 | */ 26 | int ZEXPORT uncompress (dest, destLen, source, sourceLen) 27 | Bytef *dest; 28 | uLongf *destLen; 29 | const Bytef *source; 30 | uLong sourceLen; 31 | { 32 | z_stream stream; 33 | int err; 34 | 35 | stream.next_in = (Bytef*)source; 36 | stream.avail_in = (uInt)sourceLen; 37 | /* Check for source > 64K on 16-bit machine: */ 38 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 39 | 40 | stream.next_out = dest; 41 | stream.avail_out = (uInt)*destLen; 42 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 43 | 44 | stream.zalloc = (alloc_func)0; 45 | stream.zfree = (free_func)0; 46 | 47 | err = inflateInit(&stream); 48 | if (err != Z_OK) return err; 49 | 50 | err = inflate(&stream, Z_FINISH); 51 | if (err != Z_STREAM_END) { 52 | inflateEnd(&stream); 53 | if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) 54 | return Z_DATA_ERROR; 55 | return err; 56 | } 57 | *destLen = stream.total_out; 58 | 59 | err = inflateEnd(&stream); 60 | return err; 61 | } 62 | -------------------------------------------------------------------------------- /nulldc/plugins/ImgReader/exports.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | dcGetInterface -------------------------------------------------------------------------------- /nulldc/plugins/ImgReader/gd_driver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ImgReader.h" 3 | 4 | typedef void DriveRead(u8 * buff,u32 StartSector,u32 SectorCount,u32 secsz); 5 | typedef void DriveGetToc(u32* toc,DiskArea area); 6 | 7 | typedef DiscType DriveGetType(); 8 | typedef void DriveInit(); 9 | typedef void DriveTerm(); -------------------------------------------------------------------------------- /nulldc/plugins/ImgReader/gdi.cpp: -------------------------------------------------------------------------------- 1 | #include "gdi.h" 2 | 3 | Disc* load_gdi(wchar* file_) 4 | { 5 | char file[512]; 6 | u32 iso_tc; 7 | Disc* disc = new Disc(); 8 | 9 | wcstombs(file,file_,512); 10 | //memset(&gdi_toc,0xFFFFFFFF,sizeof(gdi_toc)); 11 | //memset(&gdi_ses,0xFFFFFFFF,sizeof(gdi_ses)); 12 | FILE* t=fopen(file,"rb"); 13 | if (!t) 14 | return 0; 15 | fscanf(t,"%d\r\n",&iso_tc); 16 | printf("\nGDI : %d tracks\n",iso_tc); 17 | 18 | char temp[512]; 19 | char path[512]; 20 | strcpy(path,file); 21 | size_t len=strlen(file); 22 | while (len>2) 23 | { 24 | if (path[len]=='\\') 25 | break; 26 | len--; 27 | } 28 | len++; 29 | char* pathptr=&path[len]; 30 | u32 TRACK=0,FADS=0,CTRL=0,SSIZE=0; 31 | s32 OFFSET=0; 32 | for (u32 i=0;itracks.push_back( 38 | while(iswspace(fgetc(t))) ; 39 | fseek(t,-1,SEEK_CUR); 40 | if (fgetc(t)=='"') 41 | { 42 | char c; 43 | int i=0; 44 | while((c=fgetc(t))!='"') 45 | temp[i++]=c; 46 | temp[i]=0; 47 | } 48 | else 49 | { 50 | fseek(t,-1,SEEK_CUR); 51 | fscanf(t,"%s",temp); 52 | } 53 | 54 | fscanf(t,"%d\r\n",&OFFSET); 55 | printf("file[%d] \"%s\": FAD:%d, CTRL:%d, SSIZE:%d, OFFSET:%d\n",TRACK,temp,FADS,CTRL,SSIZE,OFFSET); 56 | 57 | 58 | 59 | Track t; 60 | t.ADDR=0; 61 | t.StartFAD=FADS+150; 62 | t.EndFAD=0; //fill it in 63 | t.file=0; 64 | 65 | if (SSIZE!=0) 66 | { 67 | strcpy(pathptr,temp); 68 | t.file = new RawTrackFile(fopen(path,"rb"),OFFSET,t.StartFAD,SSIZE); 69 | } 70 | disc->tracks.push_back(t); 71 | } 72 | 73 | disc->FillGDSession(); 74 | 75 | return disc; 76 | } 77 | 78 | 79 | Disc* gdi_parse(wchar* file) 80 | { 81 | size_t len=wcslen(file); 82 | if (len>4) 83 | { 84 | if (_tcsicmp( &file[len-4],L".gdi")==0) 85 | { 86 | return load_gdi(file); 87 | } 88 | } 89 | return 0; 90 | } 91 | 92 | void iso_term() 93 | { 94 | } -------------------------------------------------------------------------------- /nulldc/plugins/ImgReader/gdi.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "common.h" 3 | 4 | Disc* gdi_parse(wchar* file); -------------------------------------------------------------------------------- /nulldc/plugins/ImgReader/ioctl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "common.h" 3 | 4 | Disc* ioctl_parse(wchar* file); -------------------------------------------------------------------------------- /nulldc/plugins/ImgReader/mds.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "common.h" 3 | Disc* mds_parse(wchar* fname); 4 | void FASTCALL mds_DriveReadSector(u8 * buff,u32 StartSector,u32 SectorCount,u32 secsz); 5 | void mds_DriveGetTocInfo(TocInfo* toc,DiskArea area); 6 | u32 FASTCALL mds_DriveGetDiscType(); 7 | bool mds_init(wchar* file); 8 | void mds_term(); 9 | void mds_GetSessionsInfo(SessionInfo* sessions); -------------------------------------------------------------------------------- /nulldc/plugins/ImgReader/mds_reader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ImgReader.h" 3 | #include 4 | #include 5 | #include 6 | 7 | typedef struct _track { 8 | int track; 9 | int mode; 10 | int flags; 11 | 12 | int pmin; 13 | int psec; 14 | int pfrm; 15 | 16 | int sectorsize; 17 | int sector; 18 | int sectors; 19 | int pregap; 20 | __int64 offset; 21 | } strack; 22 | 23 | typedef struct _session 24 | { 25 | int session; 26 | int pregap; 27 | int sectors; 28 | int datablocks; 29 | int leadinblocks; 30 | int last_track; 31 | 32 | int something1; 33 | int something2; 34 | 35 | int datablocks_offset; 36 | int extrablocks_offset; 37 | 38 | strack tracks[256]; 39 | int ntracks; 40 | } session; 41 | 42 | extern session sessions[256]; 43 | extern session* mds_sessions; 44 | extern int nsessions; 45 | 46 | bool parse_mds(wchar *mds_filename,bool verbose); 47 | bool parse_nrg(wchar *nrg_filename,bool verbose); -------------------------------------------------------------------------------- /nulldc/plugins/ImgReader/pfctoc.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skmp/nullDC-v1/1611c3cf0aa2755611455aa7a02b4f62babee7bd/nulldc/plugins/ImgReader/pfctoc.lib -------------------------------------------------------------------------------- /nulldc/plugins/ImgReader/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by UI.rc 4 | // 5 | #define IDCANCEL2 3 6 | #define IDD_FILESELECT 101 7 | #define IDC_IMGPATH 1001 8 | #define IDC_BROWSE 1002 9 | #define IDC_NODISK 1003 10 | 11 | // Next default values for new objects 12 | // 13 | #ifdef APSTUDIO_INVOKED 14 | #ifndef APSTUDIO_READONLY_SYMBOLS 15 | #define _APS_NEXT_RESOURCE_VALUE 102 16 | #define _APS_NEXT_COMMAND_VALUE 40001 17 | #define _APS_NEXT_CONTROL_VALUE 1004 18 | #define _APS_NEXT_SYMED_VALUE 101 19 | #endif 20 | #endif 21 | -------------------------------------------------------------------------------- /nulldc/plugins/ImgReader/ui.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skmp/nullDC-v1/1611c3cf0aa2755611455aa7a02b4f62babee7bd/nulldc/plugins/ImgReader/ui.h -------------------------------------------------------------------------------- /nulldc/plugins/PuruPuru/Devices.h: -------------------------------------------------------------------------------- 1 | #include "PuruPuru.h" 2 | 3 | ////////////////////////////////////////////////////////////////////////////////////////// 4 | // General Plugin Functions 5 | // ------------------------ 6 | 7 | // ControllerDMA 8 | // ------------- 9 | // http://mc.pp.se/dc/controller.html 10 | 11 | // Based on Gigaherz solution 12 | #define wStringX(str, len) {int i; for(i=0;i 14 | 15 | ////////////////////////////////////////////////////////////////////////////////////////// 16 | // Config dialog functions 17 | // ----------------------- 18 | 19 | bool GetInputSDL(HWND hDlg, int buttonid, int controller); 20 | bool GetInputXInput(HWND hDlg, int buttonid, int controller); 21 | bool GetInputKey(HWND hDlg, int buttonid, int controller); 22 | 23 | void UpdateVisibleItems(HWND hDlg, int controllertype); 24 | 25 | void GetControllerAll(HWND hDlg, int controller); 26 | void SetControllerAll(HWND hDlg, int controller); 27 | 28 | void GetButton(HWND hDlg, int item, wchar* Receiver); 29 | void SetButton(HWND hDlg, int item, wchar* value); 30 | 31 | void OpenAbout(HINSTANCE abouthInstance, HWND _hParent); 32 | 33 | BOOL CALLBACK AboutDlg(HWND abouthWnd, UINT message, WPARAM wParam, LPARAM lParam); 34 | -------------------------------------------------------------------------------- /nulldc/plugins/PuruPuru/exports.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | dcGetInterface -------------------------------------------------------------------------------- /nulldc/plugins/PuruPuru/images/ICON_OFF.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skmp/nullDC-v1/1611c3cf0aa2755611455aa7a02b4f62babee7bd/nulldc/plugins/PuruPuru/images/ICON_OFF.bmp -------------------------------------------------------------------------------- /nulldc/plugins/PuruPuru/images/ICON_ON.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skmp/nullDC-v1/1611c3cf0aa2755611455aa7a02b4f62babee7bd/nulldc/plugins/PuruPuru/images/ICON_ON.bmp -------------------------------------------------------------------------------- /nulldc/plugins/PuruPuru/images/ICON_ON2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skmp/nullDC-v1/1611c3cf0aa2755611455aa7a02b4f62babee7bd/nulldc/plugins/PuruPuru/images/ICON_ON2.bmp -------------------------------------------------------------------------------- /nulldc/plugins/PuruPuru/images/Naomi.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skmp/nullDC-v1/1611c3cf0aa2755611455aa7a02b4f62babee7bd/nulldc/plugins/PuruPuru/images/Naomi.bmp -------------------------------------------------------------------------------- /nulldc/plugins/PuruPuru/images/full_dreamcast_controller.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skmp/nullDC-v1/1611c3cf0aa2755611455aa7a02b4f62babee7bd/nulldc/plugins/PuruPuru/images/full_dreamcast_controller.bmp -------------------------------------------------------------------------------- /nulldc/plugins/PuruPuru/images/purupurulogo.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skmp/nullDC-v1/1611c3cf0aa2755611455aa7a02b4f62babee7bd/nulldc/plugins/PuruPuru/images/purupurulogo.bmp -------------------------------------------------------------------------------- /nulldc/plugins/XMaple/ArcadeStick.cpp: -------------------------------------------------------------------------------- 1 | #include "FT0.h" 2 | #include "ArcadeStick.h" 3 | 4 | #include "XMaple.h" // for debug log crapro 5 | 6 | namespace EmulatedDevices 7 | { 8 | 9 | ArcadeStick::ArcadeStick(maple_device_instance* instance) 10 | : FT0(instance) 11 | { 12 | m_deviceID = ID_ARCADESTICK; 13 | m_FuncDef[0] = 0xFF070000; 14 | m_strName = "Arcade Stick"; 15 | m_mAstandby = 0x012C; 16 | m_mAmax = 0x0190; 17 | m_strNameEx = "Version 1.000,1998/05/25,315-6125- AC"; 18 | 19 | m_buttonMask = 0xF800; // DPad2, D 20 | } 21 | 22 | u32 ArcadeStick::DMA(u32 Command, 23 | u32* buffer_in, u32 buffer_in_len, 24 | u32* buffer_out, u32& buffer_out_len) 25 | { 26 | u8* buffer_out_b = (u8*)buffer_out; 27 | 28 | u32 ret; 29 | if ((ret = FT0::DMA(Command, buffer_in, buffer_in_len, buffer_out, buffer_out_len)) == 0) 30 | { 31 | switch (Command) 32 | { 33 | case 0: // bogus 34 | default: 35 | printf("UNKNOWN MAPLE COMMAND %d (sent to %s)\n", Command, m_strName); 36 | return CommandUnknown; 37 | } 38 | } 39 | else 40 | return ret; 41 | } 42 | 43 | } //namespace 44 | -------------------------------------------------------------------------------- /nulldc/plugins/XMaple/ArcadeStick.h: -------------------------------------------------------------------------------- 1 | // Arcade Stick (svs) 2 | #pragma once 3 | 4 | namespace EmulatedDevices 5 | { 6 | 7 | class ArcadeStick : public FT0 8 | { 9 | public: 10 | ArcadeStick(maple_device_instance* instance); 11 | 12 | u32 DMA(u32 Command, 13 | u32* buffer_in, u32 buffer_in_len, 14 | u32* buffer_out, u32& buffer_out_len); 15 | }; 16 | 17 | } //namespace 18 | 19 | -------------------------------------------------------------------------------- /nulldc/plugins/XMaple/DInputBackend.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skmp/nullDC-v1/1611c3cf0aa2755611455aa7a02b4f62babee7bd/nulldc/plugins/XMaple/DInputBackend.cpp -------------------------------------------------------------------------------- /nulldc/plugins/XMaple/DInputBackend.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /nulldc/plugins/XMaple/Device.cpp: -------------------------------------------------------------------------------- 1 | class MapleDevice 2 | { 3 | }; 4 | -------------------------------------------------------------------------------- /nulldc/plugins/XMaple/Device.hpp: -------------------------------------------------------------------------------- 1 | // even lower than FTx classes... 2 | #ifndef MAPLEDEVICE_H 3 | #define MAPLEDEVICE_H 4 | 5 | class MapleDevice 6 | { 7 | public 8 | MapleDevice(); 9 | }; 10 | 11 | #endif //MAPLEDEVICE_H 12 | -------------------------------------------------------------------------------- /nulldc/plugins/XMaple/DreameyeMic.cpp: -------------------------------------------------------------------------------- 1 | #include "FT4.h" 2 | #include "DreameyeMic.h" 3 | 4 | #include "XMaple.h" // for debug log crapro 5 | 6 | namespace EmulatedDevices 7 | { 8 | 9 | DreameyeMic::DreameyeMic(maple_subdevice_instance* instance) 10 | : FT4(instance) 11 | { 12 | m_deviceID = ID_DREAMEYEMIC; 13 | m_FuncDef[0] = 0x3F000000; 14 | m_strName = "MicDevice for Dreameye"; 15 | m_mAstandby = 0x012C; 16 | m_mAmax = 0x012C; 17 | m_strNameEx = "Version 1.000,2000/02/24,315-6182A ," 18 | "S41(SegaSoundSamplingSystem)/SamplingRate10.9090or8.000kHz" 19 | "/Bit14or8bit/NTSC/PAL/Consumer Deveropment & Mamufacturing DIV.CSRD"; 20 | } 21 | 22 | u32 DreameyeMic::DMA(u32 Command, 23 | u32* buffer_in, u32 buffer_in_len, 24 | u32* buffer_out, u32& buffer_out_len) 25 | { 26 | u8* buffer_out_b = (u8*)buffer_out; 27 | 28 | switch (Command) 29 | { 30 | case GetStatus: 31 | //functionality info 32 | w32(m_FuncType); 33 | w32(m_FuncDef[0]); 34 | w32(m_FuncDef[1]); 35 | w32(m_FuncDef[2]); 36 | w8(m_Region); 37 | w8(m_Direction); 38 | wString(m_strName, 30); 39 | wString(m_License, 60); 40 | w16(m_mAstandby); 41 | w16(m_mAmax); 42 | DEBUG_LOG("GetStatus\n"); 43 | return DeviceInfo; 44 | 45 | case GetStatusAll: 46 | w32(m_FuncType); 47 | w32(m_FuncDef[0]); 48 | w32(m_FuncDef[1]); 49 | w32(m_FuncDef[2]); 50 | w8(m_Region); 51 | w8(m_Direction); 52 | wString(m_strName, 30); 53 | wString(m_License, 60); 54 | w16(m_mAstandby); 55 | w16(m_mAmax); 56 | wString(m_strNameEx, 172); // TODO verify 57 | DEBUG_LOG("GetStatusAll\n"); 58 | return DeviceInfoEx; 59 | 60 | default: 61 | printf("UNKNOWN MAPLE COMMAND %d (sent to %s)\n", Command, m_strName); 62 | return CommandUnknown; 63 | } 64 | } 65 | 66 | } //namespace 67 | -------------------------------------------------------------------------------- /nulldc/plugins/XMaple/DreameyeMic.h: -------------------------------------------------------------------------------- 1 | // Dreameye Mic 2 | #pragma once 3 | 4 | namespace EmulatedDevices 5 | { 6 | 7 | class DreameyeMic : public FT4 8 | { 9 | public: 10 | DreameyeMic(maple_subdevice_instance* instance); 11 | 12 | u32 DMA(u32 Command, 13 | u32* buffer_in, u32 buffer_in_len, 14 | u32* buffer_out, u32& buffer_out_len); 15 | }; 16 | 17 | } //namespace 18 | 19 | -------------------------------------------------------------------------------- /nulldc/plugins/XMaple/FT0.h: -------------------------------------------------------------------------------- 1 | // base class for controllers (function type 0) 2 | // also serves as a factory 3 | #pragma once 4 | 5 | #include "MapleInterface.h" 6 | 7 | namespace EmulatedDevices 8 | { 9 | 10 | #define FUNCTION_TYPE0 (1 << 24) 11 | 12 | // CONT_* bits 13 | #define CONT_BUTTON_C (1 << 0) 14 | #define CONT_BUTTON_B (1 << 1) 15 | #define CONT_BUTTON_A (1 << 2) 16 | #define CONT_BUTTON_START (1 << 3) 17 | #define CONT_DPAD_UP (1 << 4) 18 | #define CONT_DPAD_DOWN (1 << 5) 19 | #define CONT_DPAD_LEFT (1 << 6) 20 | #define CONT_DPAD_RIGHT (1 << 7) 21 | #define CONT_BUTTON_Z (1 << 8) 22 | #define CONT_BUTTON_Y (1 << 9) 23 | #define CONT_BUTTON_X (1 << 10) 24 | #define CONT_BUTTON_D (1 << 11) 25 | #define CONT_DPAD2_UP (1 << 12) 26 | #define CONT_DPAD2_DOWN (1 << 13) 27 | #define CONT_DPAD2_LEFT (1 << 14) 28 | #define CONT_DPAD2_RIGHT (1 << 15) 29 | 30 | class FT0 : public MapleInterface 31 | { 32 | public: 33 | FT0(maple_device_instance* instance); 34 | 35 | u32 DMA(u32 Command, 36 | u32* buffer_in, u32 buffer_in_len, 37 | u32* buffer_out, u32& buffer_out_len); 38 | 39 | //needed to get port/etc 40 | maple_device_instance* m_instance; 41 | 42 | struct SStatus 43 | { //8 bytes 44 | u16 buttons; // ORd CONT_BUTTON* bits 45 | u8 rtrig; // right trigger 46 | u8 ltrig; // left trigger 47 | u8 joyx; // joystick X 48 | u8 joyy; // joystick Y 49 | u8 joy2x; // second joystick X 50 | u8 joy2y; // second joystick Y 51 | }; 52 | SStatus m_status; 53 | 54 | // buttons the device DOES NOT support 55 | u16 m_buttonMask; 56 | }; 57 | 58 | extern FT0* CreateFT0(u32 DeviceID, maple_device_instance* instance); 59 | 60 | } //namespace 61 | -------------------------------------------------------------------------------- /nulldc/plugins/XMaple/FT4.cpp: -------------------------------------------------------------------------------- 1 | #include "FT4.h" 2 | #include "XMaple.h" 3 | #include "Mic.h" 4 | #include "DreameyeMic.h" 5 | 6 | namespace EmulatedDevices 7 | { 8 | 9 | FT4::FT4(maple_subdevice_instance* instance) 10 | : m_instance(instance) 11 | { 12 | m_FuncType = FUNCTION_TYPE4; 13 | 14 | m_FuncDef[1] = 0; 15 | m_FuncDef[2] = 0; 16 | m_Region = REGION_USA|REGION_JAP|REGION_ASIA|REGION_EURO; 17 | m_Direction = DIRECTION_DOWN; 18 | m_License = "Produced By or Under License From SEGA ENTERPRISES,LTD."; 19 | 20 | m_xpad = instance->port >> 6; 21 | } 22 | 23 | ////////////////////////////////////////////////////////////////////////// 24 | // Make them bitches! 25 | FT4* CreateFT4(u32 DeviceID, maple_subdevice_instance* instance) 26 | { 27 | switch (DeviceID) 28 | { 29 | case ID_MIC: 30 | return new Mic(instance); 31 | break; 32 | 33 | case ID_DREAMEYEMIC: 34 | return new DreameyeMic(instance); 35 | break; 36 | 37 | default: 38 | return NULL; 39 | break; 40 | } 41 | } 42 | 43 | } //namespace 44 | -------------------------------------------------------------------------------- /nulldc/plugins/XMaple/FT4.h: -------------------------------------------------------------------------------- 1 | // base class for audio input (function type 4) 2 | // also serves as a factory 3 | #pragma once 4 | 5 | #include "MapleInterface.h" 6 | 7 | namespace EmulatedDevices 8 | { 9 | 10 | #define FUNCTION_TYPE4 0x10000000 11 | 12 | class FT4 : public MapleInterface 13 | { 14 | public: 15 | FT4(maple_subdevice_instance* instance); 16 | 17 | virtual u32 DMA(u32 Command, 18 | u32* buffer_in, u32 buffer_in_len, 19 | u32* buffer_out, u32& buffer_out_len) = 0; 20 | 21 | //needed to get port/etc 22 | maple_subdevice_instance* m_instance; 23 | }; 24 | 25 | extern FT4* CreateFT4(u32 DeviceID, maple_subdevice_instance* instance); 26 | 27 | } //namespace 28 | -------------------------------------------------------------------------------- /nulldc/plugins/XMaple/FT8.cpp: -------------------------------------------------------------------------------- 1 | #include "FT8.h" 2 | #include "XMaple.h" 3 | #include "Maxi.h" 4 | 5 | namespace EmulatedDevices 6 | { 7 | 8 | FT8::FT8(maple_subdevice_instance* instance) 9 | : m_instance(instance) 10 | { 11 | m_FuncType = FUNCTION_TYPE8; 12 | 13 | m_FuncDef[1] = 0; 14 | m_FuncDef[2] = 0; 15 | m_Region = REGION_ALL; 16 | m_Direction = DIRECTION_UP; 17 | m_License = "Produced By or Under License From SEGA ENTERPRISES,LTD."; 18 | 19 | m_xpad = instance->port >> 6; 20 | } 21 | 22 | ////////////////////////////////////////////////////////////////////////// 23 | // Make them bitches! 24 | FT8* CreateFT8(u32 DeviceID, maple_subdevice_instance* instance) 25 | { 26 | switch (DeviceID) 27 | { 28 | case ID_PURUPURUPACK: 29 | return new Maxi(instance); 30 | break; 31 | 32 | default: 33 | return NULL; 34 | break; 35 | } 36 | } 37 | 38 | } //namespace 39 | -------------------------------------------------------------------------------- /nulldc/plugins/XMaple/MapleInterface.h: -------------------------------------------------------------------------------- 1 | // The lowest of the low! woot 2 | #pragma once 3 | 4 | #include 5 | #include "..\..\nullDC\plugins\plugin_header.h" 6 | 7 | namespace EmulatedDevices 8 | { 9 | 10 | enum 11 | { 12 | // May be ORd 13 | REGION_USA = 0x01, 14 | REGION_JAP = 0x02, 15 | REGION_ASIA = 0x04, 16 | REGION_EURO = 0x08, 17 | REGION_ALL = 0xFF, // Only use this, really... 18 | }; 19 | 20 | enum 21 | { 22 | DIRECTION_UP = 0, // We only really use Up, anyways... 23 | DIRECTION_DOWN = 1, 24 | DIRECTION_LEFT = 2, 25 | DIRECTION_RIGHT = 3, 26 | }; 27 | 28 | // Maple commands and return codes 29 | enum 30 | { 31 | GetStatus = 0x01, 32 | GetStatusAll, 33 | DeviceReset, 34 | DeviceKill, 35 | 36 | //return codes 37 | DeviceInfo, 38 | DeviceInfoEx, 39 | DeviceReply, 40 | DataTransfer, 41 | 42 | GetCondition, 43 | GetMediaInfo, 44 | BlockRead, 45 | BlockWrite, 46 | GetLastError, 47 | SetCondition, 48 | FT4Control, 49 | ARControl, 50 | 51 | 52 | //errors 53 | ARError = 0xF9, 54 | LCDError, 55 | FileError, 56 | TransmitAgain, 57 | CommandUnknown, 58 | FuncTypeUnknown 59 | }; 60 | 61 | class MapleInterface 62 | { 63 | protected: 64 | // Device ID 65 | u32 m_FuncType; 66 | u32 m_FuncDef[3]; 67 | // Destination code 68 | u8 m_Region; 69 | // Connection direction 70 | u8 m_Direction; 71 | // Product name 72 | const char* m_strName; 73 | // License 74 | const char* m_License; 75 | // Standby current consumption 76 | u16 m_mAstandby; 77 | // Maximum current consumption 78 | u16 m_mAmax; 79 | // Free Device Status 80 | const char* m_strNameEx; 81 | 82 | // the device ID as determined by nullDC 83 | u32 m_deviceID; 84 | // the xpad this device is mapped to 85 | u8 m_xpad; 86 | 87 | public: 88 | virtual u32 DMA(u32 Command, 89 | u32* buffer_in, u32 buffer_in_len, 90 | u32* buffer_out, u32& buffer_out_len) = 0; 91 | 92 | static u32 FASTCALL ClassDMA(void* device_instance, 93 | u32 Command, 94 | u32* buffer_in, u32 buffer_in_len, 95 | u32* buffer_out, u32& buffer_out_len) 96 | { 97 | //the class pointer is the device_instance, just cast it 98 | MapleInterface * pthis = (MapleInterface*)device_instance; 99 | return pthis->DMA(Command, buffer_in, buffer_in_len, buffer_out, buffer_out_len); 100 | } 101 | 102 | void SetXPad(u8 pad) {m_xpad = pad;} 103 | u8 GetXPad() {return m_xpad;} 104 | u32 GetID() {return m_deviceID;} 105 | }; 106 | 107 | } //namespace -------------------------------------------------------------------------------- /nulldc/plugins/XMaple/Maxi.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skmp/nullDC-v1/1611c3cf0aa2755611455aa7a02b4f62babee7bd/nulldc/plugins/XMaple/Maxi.cpp -------------------------------------------------------------------------------- /nulldc/plugins/XMaple/Maxi.h: -------------------------------------------------------------------------------- 1 | // Maxi (puru puru pack) 2 | #pragma once 3 | 4 | namespace EmulatedDevices 5 | { 6 | 7 | class Maxi : public FT8 8 | { 9 | public: 10 | Maxi(maple_subdevice_instance* instance); 11 | 12 | u32 DMA(u32 Command, 13 | u32* buffer_in, u32 buffer_in_len, 14 | u32* buffer_out, u32& buffer_out_len); 15 | 16 | void StartVibThread(); 17 | void StopVibThread(); 18 | 19 | // void UseFreqScaling(bool enable); 20 | }; 21 | 22 | } //namespace 23 | -------------------------------------------------------------------------------- /nulldc/plugins/XMaple/Mic.cpp: -------------------------------------------------------------------------------- 1 | #include "FT4.h" 2 | #include "Mic.h" 3 | 4 | #include "XMaple.h" // for debug log crapro 5 | 6 | namespace EmulatedDevices 7 | { 8 | 9 | Mic::Mic(maple_subdevice_instance* instance) 10 | : FT4(instance) 11 | { 12 | m_deviceID = ID_MIC; 13 | m_FuncDef[0] = 0x0F000000; 14 | m_strName = "SoundInputPeripheral (S.I.P.)"; 15 | m_mAstandby = 0x012C; 16 | m_mAmax = 0x012C; 17 | m_strNameEx = "Version 1.000,1998/05/22,315-6182 ," 18 | "S4(SegaSoundSamplingSystem)/SamplingRate11.0257or8.085kHz" 19 | "/Bit14or8bit/NTSC only/Consumer Deveropment & Mamufacturing DIV.CSPD2-3"; 20 | } 21 | 22 | u32 Mic::DMA(u32 Command, 23 | u32* buffer_in, u32 buffer_in_len, 24 | u32* buffer_out, u32& buffer_out_len) 25 | { 26 | u8* buffer_out_b = (u8*)buffer_out; 27 | 28 | // Buffer overflow 29 | if (buffer_in_len > 8) 30 | return CommandUnknown; 31 | 32 | switch (Command) 33 | { 34 | case GetStatus: 35 | //functionality info 36 | w32(m_FuncType); 37 | w32(m_FuncDef[0]); 38 | w32(m_FuncDef[1]); 39 | w32(m_FuncDef[2]); 40 | w8(m_Region); 41 | w8(m_Direction); 42 | wString(m_strName, 30); 43 | wString(m_License, 60); 44 | w16(m_mAstandby); 45 | w16(m_mAmax); 46 | DEBUG_LOG("GetStatus\n"); 47 | return DeviceInfo; 48 | 49 | case GetStatusAll: 50 | w32(m_FuncType); 51 | w32(m_FuncDef[0]); 52 | w32(m_FuncDef[1]); 53 | w32(m_FuncDef[2]); 54 | w8(m_Region); 55 | w8(m_Direction); 56 | wString(m_strName, 30); 57 | wString(m_License, 60); 58 | w16(m_mAstandby); 59 | w16(m_mAmax); 60 | wString(m_strNameEx, 172); // TODO verify 61 | DEBUG_LOG("GetStatusAll\n"); 62 | return DeviceInfoEx; 63 | 64 | case GetCondition: 65 | return DataTransfer; 66 | 67 | default: 68 | printf("UNKNOWN MAPLE COMMAND %d (sent to %s)\n", Command, m_strName); 69 | return CommandUnknown; 70 | } 71 | } 72 | 73 | } //namespace 74 | -------------------------------------------------------------------------------- /nulldc/plugins/XMaple/Mic.h: -------------------------------------------------------------------------------- 1 | // Mic (plain mic, not for dreameye) 2 | #pragma once 3 | namespace EmulatedDevices 4 | { 5 | 6 | class Mic : public FT4 7 | { 8 | public: 9 | Mic(maple_subdevice_instance* instance); 10 | 11 | u32 DMA(u32 Command, 12 | u32* buffer_in, u32 buffer_in_len, 13 | u32* buffer_out, u32& buffer_out_len); 14 | }; 15 | 16 | } //namespace 17 | -------------------------------------------------------------------------------- /nulldc/plugins/XMaple/StandardController.cpp: -------------------------------------------------------------------------------- 1 | #include "FT0.h" 2 | #include "StandardController.h" 3 | #include "XInputBackend.h" 4 | #include "XMaple.h" // for debug log crapro 5 | 6 | namespace EmulatedDevices 7 | { 8 | 9 | StdController::StdController(maple_device_instance* instance) 10 | : FT0(instance) 11 | { 12 | m_deviceID = ID_STDCONTROLLER; 13 | m_FuncDef[0] = 0xFE060F00; 14 | m_strName = "Dreamcast Controller"; 15 | m_mAstandby = 0x01AE; 16 | m_mAmax = 0x01F4; 17 | m_strNameEx = "Version 1.000,1998/05/11,315-6125-AB ,Analog Module: The 4th Edition. 05/08"; 18 | 19 | m_buttonMask = 0xF901; // DPad2, C, D, Z 20 | } 21 | 22 | u32 StdController::DMA(u32 Command, 23 | u32* buffer_in, u32 buffer_in_len, 24 | u32* buffer_out, u32& buffer_out_len) 25 | { 26 | u8* buffer_out_b = (u8*)buffer_out; 27 | 28 | u32 ret; 29 | if ((ret = FT0::DMA(Command, buffer_in, buffer_in_len, buffer_out, buffer_out_len)) == 0) 30 | { 31 | switch (Command) 32 | { 33 | case 0: // bogus 34 | default: 35 | printf("UNKNOWN MAPLE COMMAND %d (sent to %s)\n", Command, m_strName); 36 | return CommandUnknown; 37 | } 38 | } 39 | else 40 | return ret; 41 | } 42 | 43 | } //namespace 44 | -------------------------------------------------------------------------------- /nulldc/plugins/XMaple/StandardController.h: -------------------------------------------------------------------------------- 1 | // standard controller (sdhwr) 2 | #pragma once 3 | 4 | namespace EmulatedDevices 5 | { 6 | 7 | class StdController : public FT0 8 | { 9 | public: 10 | StdController(maple_device_instance* instance); 11 | 12 | u32 DMA(u32 Command, 13 | u32* buffer_in, u32 buffer_in_len, 14 | u32* buffer_out, u32& buffer_out_len); 15 | }; 16 | 17 | } //namespace 18 | -------------------------------------------------------------------------------- /nulldc/plugins/XMaple/Twinstick.cpp: -------------------------------------------------------------------------------- 1 | #include "FT0.h" 2 | #include "Twinstick.h" 3 | 4 | #include "XMaple.h" // for debug log crapro 5 | 6 | namespace EmulatedDevices 7 | { 8 | 9 | Twinstick::Twinstick(maple_device_instance* instance) 10 | : FT0(instance) 11 | { 12 | m_deviceID = ID_TWINSTICK; 13 | m_FuncDef[0] = 0xFEFE0000; 14 | m_strName = "Twin Stick"; 15 | m_mAstandby = 0x00DC; 16 | m_mAmax = 0x012C; 17 | m_strNameEx = "Version 1.000,1999/05/21,315-6211-AF ,Ra,La,Da,Ua,Rb,Lb,Db,Ub,A,B,X,Y,D,S key"; 18 | 19 | m_buttonMask = 0x0101; // C, Z 20 | } 21 | 22 | u32 Twinstick::DMA(u32 Command, 23 | u32* buffer_in, u32 buffer_in_len, 24 | u32* buffer_out, u32& buffer_out_len) 25 | { 26 | u8* buffer_out_b = (u8*)buffer_out; 27 | 28 | u32 ret; 29 | if ((ret = FT0::DMA(Command, buffer_in, buffer_in_len, buffer_out, buffer_out_len)) == 0) 30 | { 31 | switch (Command) 32 | { 33 | case 0: // bogus 34 | default: 35 | printf("UNKNOWN MAPLE COMMAND %d (sent to %s)\n", Command, m_strName); 36 | return CommandUnknown; 37 | } 38 | } 39 | else 40 | return ret; 41 | } 42 | 43 | } //namespace 44 | -------------------------------------------------------------------------------- /nulldc/plugins/XMaple/Twinstick.h: -------------------------------------------------------------------------------- 1 | // Twinstick (svo) 2 | #pragma once 3 | 4 | namespace EmulatedDevices 5 | { 6 | 7 | class Twinstick : public FT0 8 | { 9 | public: 10 | Twinstick(maple_device_instance* instance); 11 | 12 | u32 DMA(u32 Command, 13 | u32* buffer_in, u32 buffer_in_len, 14 | u32* buffer_out, u32& buffer_out_len); 15 | }; 16 | 17 | } //namespace 18 | -------------------------------------------------------------------------------- /nulldc/plugins/XMaple/XInputBackend.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "FT0.h" 3 | 4 | namespace XInput 5 | { 6 | 7 | // Returns false if there's an xinput error - we should hot-unplug 8 | bool Read(int XPadPlayer, u32 deviceType, EmulatedDevices::FT0::SStatus* status); 9 | 10 | // Returns true if the pad is ready to go 11 | bool IsConnected(int XPadPlayer); 12 | 13 | void StopRumble(int XPadPlayer); 14 | 15 | void VibrationThread(void* _status); 16 | 17 | } //namespace -------------------------------------------------------------------------------- /nulldc/plugins/XMaple/XMaple.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "..\..\nullDC\plugins\plugin_header.h" 4 | #include 5 | #include 6 | 7 | #include "MapleInterface.h" 8 | #include "XInputBackend.h" 9 | 10 | 11 | ////////////////////////////////////////////////////////////////////////// 12 | // should probably be moved to MapleInterface or smth 13 | // Handy write funcs for DMA....needs rethinking (requires buffer_out_b in each DMA) 14 | #define w32(data) *(u32*)buffer_out_b=(data);buffer_out_b+=4;buffer_out_len+=4 15 | #define w16(data) *(u16*)buffer_out_b=(data);buffer_out_b+=2;buffer_out_len+=2 16 | #define w8(data) *(u8*)buffer_out_b=(data);buffer_out_b+=1;buffer_out_len+=1 17 | // write str to buffer, pad with 0x20 (space) if str < len 18 | #define wString(str, len) for (u32 i = 0; i < len; ++i){if (str[i] != 0){w8((u8)str[i]);}else{while (i < len){w8(0x20);++i;}}} 19 | 20 | ////////////////////////////////////////////////////////////////////////// 21 | // Crapros 22 | #ifdef _DEBUG 23 | // ya let's spam console in debug build 24 | #define DEBUG_LOG(...) printf(__VA_ARGS__); 25 | // break into debugger 26 | #define dbgbreak {while(1) __noop;} 27 | // print some info and crash 28 | #define verify(x) if((x)==false){ \ 29 | printf("Verify Failed : " #x "\n in %s -> %s : %d \n",__FUNCTION__,__FILE__,__LINE__); \ 30 | dbgbreak;} 31 | #else 32 | // just build, dammit 33 | #define DEBUG_LOG(...) 34 | #define dbgbreak 35 | #define verify(x) 36 | #endif 37 | 38 | //#pragma pack(1) 39 | 40 | extern emu_info host; 41 | 42 | ////////////////////////////////////////////////////////////////////////// 43 | // For recognizing which device the emu requests 44 | enum 45 | { 46 | ID_STDCONTROLLER, 47 | ID_TWINSTICK, 48 | ID_ARCADESTICK, 49 | ID_PURUPURUPACK, 50 | ID_MIC, 51 | ID_DREAMEYEMIC, 52 | }; 53 | 54 | static const wchar_t* deviceNames[] = 55 | { 56 | L"Controller", 57 | L"Twinstick", 58 | L"Arcade Stick", 59 | L"Puru-Puru Pak", 60 | L"Mic", 61 | L"Dreameye Mic", 62 | }; 63 | 64 | struct xmaple_settings 65 | { 66 | struct 67 | { 68 | int Deadzone; 69 | } Controller; 70 | 71 | struct 72 | { 73 | bool UseRealFreq; 74 | int Length; 75 | int Intensity; 76 | } PuruPuru; 77 | }; 78 | 79 | void loadConfig(); 80 | void saveConfig(); 81 | -------------------------------------------------------------------------------- /nulldc/plugins/XMaple/exports.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | dcGetInterface -------------------------------------------------------------------------------- /nulldc/plugins/XMaple/readme.txt: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // Mapping: 3 | ////////////////////////////////////////////////////////////////////////////// 4 | Controller: 5 | obvious 6 | ______________________________________________________________________________ 7 | Twinstick: 8 | joysticks: joysticks 9 | joystick buttons: joystick "clicks" 10 | joystick triggers: triggers 11 | Start: start 12 | D (pause): back 13 | 14 | As this is only used in virtual on, i think it's ok to use this mapping. 15 | 16 | In case you're wondering, the literal mapping is: 17 | A: right trigger 18 | B: right joystick "click" 19 | X: left trigger 20 | Y: left joystick "click" 21 | ______________________________________________________________________________ 22 | Arcade: 23 | A, B, X, Y, start, joystick: obvious 24 | C: left bumper 25 | Z: right bumper 26 | 27 | I am open to suggestions for this mapping 28 | 29 | ////////////////////////////////////////////////////////////////////////////// 30 | // Infos: 31 | ////////////////////////////////////////////////////////////////////////////// 32 | Things left to do (besides adding DInput ;)) 33 | 1) Bug squashing! 34 | I need SHOE to find bugs! :p 35 | 36 | 2) Rumble... 37 | If a game spams rumble (Under Defeat), emulation can sloowowww down... :( -------------------------------------------------------------------------------- /nulldc/plugins/drkMapleDevices/drkMapleDevices.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | 10 | 11 | Source Files 12 | 13 | 14 | 15 | 16 | Source Files 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /nulldc/plugins/drkMapleDevices/exports.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | dcGetInterface -------------------------------------------------------------------------------- /nulldc/plugins/drkMapleDevices/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by drkMapleDevices.rc 4 | // 5 | #define IDD_ConfigKeys 101 6 | #define IDD_VMU 102 7 | #define IDD_LCD 102 8 | #define IDD_DIALOG1 103 9 | #define IDC_PORTTAB 1002 10 | #define IDC_BUTTON1 1007 11 | #define IDC_BUTTON2 1008 12 | #define IDC_BUTTON3 1009 13 | #define IDC_BUTTON4 1010 14 | #define IDC_BUTTON5 1011 15 | #define IDC_BUTTON6 1012 16 | #define IDC_BUTTON7 1013 17 | #define IDC_BUTTON8 1014 18 | #define IDC_BUTTON9 1015 19 | #define IDC_BUTTON10 1016 20 | #define IDC_BUTTON11 1017 21 | #define IDC_BUTTON12 1018 22 | #define IDC_BUTTON13 1019 23 | #define IDC_STATUS 1020 24 | #define IDC_BUTTON14 1021 25 | #define IDC_BUTTON15 1022 26 | #define IDC_BUTTON16 1023 27 | #define IDC_NAOMI_UP_KEY 1023 28 | #define IDC_BUTTON17 1024 29 | #define IDC_NAOMI_LEFT_KEY 1024 30 | #define IDC_BUTTON18 1025 31 | #define IDC_BUTTON19 1026 32 | #define IDC_BUTTON20 1027 33 | #define IDC_NAOMI_RIGHT_KEY 1027 34 | #define IDC_BUTTON21 1028 35 | #define IDC_NAOMI_DOWN_KEY 1028 36 | #define IDC_BUTTON22 1029 37 | #define IDC_NAOMI_BTN0_KEY 1029 38 | #define IDC_BUTTON23 1030 39 | #define IDC_NAOMI_BTN1_KEY 1030 40 | #define IDC_NAOMI_BTN2_KEY 1031 41 | #define IDC_NAOMI_BTN3_KEY 1032 42 | #define IDC_NAOMI_BTN4_KEY 1033 43 | #define IDC_NAOMI_BTN5_KEY 1034 44 | #define IDC_NAOMI_START_KEY 1035 45 | #define IDC_NAOMI_COIN_KEY 1036 46 | #define IDC_NAOMI_SERVICE_KEY_1 1037 47 | #define IDC_NAOMI_TEST_KEY_1 1038 48 | #define IDC_NAOMI_SERVICE_KEY_2 1039 49 | #define IDC_NAOMI_TEST_KEY_2 1040 50 | 51 | // Next default values for new objects 52 | // 53 | #ifdef APSTUDIO_INVOKED 54 | #ifndef APSTUDIO_READONLY_SYMBOLS 55 | #define _APS_NEXT_RESOURCE_VALUE 104 56 | #define _APS_NEXT_COMMAND_VALUE 40001 57 | #define _APS_NEXT_CONTROL_VALUE 1041 58 | #define _APS_NEXT_SYMED_VALUE 101 59 | #endif 60 | #endif 61 | -------------------------------------------------------------------------------- /nulldc/plugins/drkPvr/Renderer_if.cpp: -------------------------------------------------------------------------------- 1 | #include "Renderer_if.h" 2 | #include "nullRend.h" 3 | #include "d3dRend.h" 4 | 5 | u32 VertexCount=0; 6 | u32 FrameCount=0; 7 | -------------------------------------------------------------------------------- /nulldc/plugins/drkPvr/Renderer_if.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "drkPvr.h" 3 | #include "ta.h" 4 | #include "TexCache.h" 5 | 6 | extern u32 VertexCount; 7 | extern u32 FrameCount; 8 | 9 | #include "d3dRend.h" 10 | #include "d3dRend11.h" 11 | #include "nullRend.h" -------------------------------------------------------------------------------- /nulldc/plugins/drkPvr/TexCache.cpp: -------------------------------------------------------------------------------- 1 | #include "TexCache.h" 2 | #include "regs.h" 3 | 4 | u32 detwiddle[2][8][1024]; 5 | //input : address in the yyyyyxxxxx format 6 | //output : address in the xyxyxyxy format 7 | //U : x resolution , V : y resolution 8 | //twidle works on 64b words 9 | u32 fastcall twiddle_fast(u32 x,u32 y,u32 bcx,u32 bcy) 10 | { 11 | return detwiddle[0][bcy][x]+detwiddle[1][bcx][y]; 12 | } 13 | 14 | u32 fastcall twiddle_razi_(u32 x,u32 y,u32 x_sz,u32 y_sz) 15 | { 16 | u32 rv=0;//low 2 bits are directly passed -> needs some misc stuff to work.However 17 | //Pvr internaly maps the 64b banks "as if" they were twidled :p 18 | 19 | u32 sh=0; 20 | x_sz>>=1; 21 | y_sz>>=1; 22 | while(x_sz!=0 || y_sz!=0) 23 | { 24 | if (y_sz) 25 | { 26 | u32 temp=y&1; 27 | rv|=temp<>=1; 30 | y>>=1; 31 | sh++; 32 | } 33 | if (x_sz) 34 | { 35 | u32 temp=x&1; 36 | rv|=temp<>=1; 39 | x>>=1; 40 | sh++; 41 | } 42 | } 43 | return rv; 44 | } 45 | 46 | u32 unpack_4_to_8_tw[16]; 47 | u32 unpack_5_to_8_tw[32]; 48 | u32 unpack_6_to_8_tw[64]; 49 | 50 | void BuildTwiddleTables() 51 | { 52 | for (u32 s=0;s<8;s++) 53 | { 54 | u32 x_sz=1024; 55 | u32 y_sz=8<>0); 68 | } 69 | 70 | for (int i=0;i<(1<<5);i++) 71 | { 72 | unpack_5_to_8_tw[i]=((i)<<3)|(i>>2); 73 | } 74 | 75 | for (int i=0;i<(1<<6);i++) 76 | { 77 | unpack_6_to_8_tw[i]=((i)<<2)|(i>>4); 78 | } 79 | } 80 | 81 | //# define twop( val, n ) twidle_razi( (val), (n),(n) ) 82 | #define twop twiddle_fast 83 | 84 | u8* vq_codebook; 85 | u32 palette_index; 86 | u32 palette_lut[1024]; 87 | bool pal_needs_update=true; 88 | u32 _pal_rev_256[4]={0}; 89 | u32 _pal_rev_16[64]={0}; 90 | u32 pal_rev_256[4]={0}; 91 | u32 pal_rev_16[64]={0}; 92 | void palette_update() 93 | { 94 | if (pal_needs_update==false) 95 | return; 96 | memcpy(pal_rev_256,_pal_rev_256,sizeof(pal_rev_256)); 97 | memcpy(pal_rev_16,_pal_rev_16,sizeof(pal_rev_16)); 98 | 99 | #define PixelPacker pp_dx 100 | pal_needs_update=false; 101 | switch(PAL_RAM_CTRL&3) 102 | { 103 | case 0: 104 | for (int i=0;i<1024;i++) 105 | { 106 | palette_lut[i]=ARGB1555_TW(PALETTE_RAM[i]); 107 | } 108 | break; 109 | 110 | case 1: 111 | for (int i=0;i<1024;i++) 112 | { 113 | palette_lut[i]=ARGB565_TW(PALETTE_RAM[i]); 114 | } 115 | break; 116 | 117 | case 2: 118 | for (int i=0;i<1024;i++) 119 | { 120 | palette_lut[i]=ARGB4444_TW(PALETTE_RAM[i]); 121 | } 122 | break; 123 | 124 | case 3: 125 | for (int i=0;i<1024;i++) 126 | { 127 | palette_lut[i]=PALETTE_RAM[i];//argb 8888 :p 128 | } 129 | break; 130 | } 131 | 132 | } -------------------------------------------------------------------------------- /nulldc/plugins/drkPvr/composition.fx: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Effect File Variables 3 | //----------------------------------------------------------------------------- 4 | 5 | float4 WindowSize:register(c0); 6 | float4 TextureSize:register(c1); 7 | 8 | 9 | sampler tex:register(s0); 10 | sampler texflt:register(s1); 11 | 12 | //----------------------------------------------------------------------------- 13 | // Vertex Definitions 14 | //----------------------------------------------------------------------------- 15 | 16 | struct VS_INPUT 17 | { 18 | float4 position : POSITION; 19 | float4 color : COLOR0; 20 | float2 texcoord : TEXCOORD0; 21 | }; 22 | 23 | struct VS_OUTPUT 24 | { 25 | float4 hposition : POSITION; 26 | float4 color : COLOR0; 27 | float2 texcoord : TEXCOORD0; 28 | float2 position : TEXCOORD1; 29 | }; 30 | 31 | //----------------------------------------------------------------------------- 32 | // Simple Vertex Shader 33 | //----------------------------------------------------------------------------- 34 | 35 | VS_OUTPUT VertexMain(VS_INPUT inp) 36 | { 37 | VS_OUTPUT outp; 38 | 39 | outp.hposition.xy=(inp.position.xy-WindowSize.zw+float2(0.5,0.5))*WindowSize.xy; 40 | outp.hposition.zw=inp.position.zw; 41 | outp.position=inp.position.xy; 42 | outp.color=inp.color; 43 | outp.texcoord=inp.texcoord; 44 | 45 | return outp; 46 | } 47 | 48 | //----------------------------------------------------------------------------- 49 | // Simple Pixel Shaders 50 | //----------------------------------------------------------------------------- 51 | 52 | float4 ps_DrawRGBA(VS_OUTPUT inp) : COLOR 53 | { 54 | float4 rv = tex2D(texflt, inp.texcoord)*inp.color; 55 | 56 | return rv; 57 | } 58 | 59 | float4 ps_DrawRGB(VS_OUTPUT inp) : COLOR 60 | { 61 | float4 rv = tex2D(texflt, inp.texcoord)*inp.color; 62 | rv.a = inp.color.a; 63 | 64 | return rv; 65 | } 66 | 67 | float4 ps_DrawA(VS_OUTPUT inp) : COLOR 68 | { 69 | float4 rv = inp.color; 70 | rv.a*=tex2D(texflt, inp.texcoord).a; 71 | 72 | return rv; 73 | } 74 | 75 | float4 ps_DrawFBz(VS_OUTPUT inp) : COLOR 76 | { 77 | float4 rv = tex2D(texflt, inp.texcoord)*inp.color; 78 | rv.a = inp.color.a; 79 | 80 | return rv; 81 | } 82 | 83 | float4 GetSubSum(float2 tc,float x,float y) 84 | { 85 | tc+=float2(x/640,y/480); 86 | return min(tex2D(texflt, tc),float4(1.2,1.2,1.2,1.2))*0.2f; 87 | } 88 | //AA! 89 | float4 ps_DrawFB(VS_OUTPUT inp) : COLOR 90 | { 91 | float2 tc= inp.texcoord; 92 | float4 rv = smoothstep(float4(0,0,0,0),float4(1,1,1,1),tex2D(texflt, inp.texcoord)); 93 | 94 | rv.a = inp.color.a; 95 | 96 | return rv; 97 | } -------------------------------------------------------------------------------- /nulldc/plugins/drkPvr/config.h: -------------------------------------------------------------------------------- 1 | #define OP_ON 1 2 | #define OP_OFF 2 3 | 4 | //TA stuff 5 | 6 | //Rendering stuff :) 7 | #define REND_D3D 1 8 | #define REND_OGL 2 9 | #define REND_SW 3 10 | #define REND_D3D_V2 4 11 | #define REND_NONE 5 12 | #define REND_D3D11 6 13 | 14 | #define REND_API REND_D3D 15 | 16 | 17 | //Debugging stuff 18 | #define DO_VERIFY OP_OFF 19 | 20 | 21 | //DO NOT EDIT -- overrides for default acording to build options 22 | #ifdef _DEBUG 23 | #undef DO_VERIFY 24 | #define DO_VERIFY OP_ON 25 | #endif -------------------------------------------------------------------------------- /nulldc/plugins/drkPvr/d3d11.fx: -------------------------------------------------------------------------------- 1 | 2 | struct VS_INPUT 3 | { 4 | float3 pos : POS; 5 | float4 col0 : COL0; 6 | float4 col1 : COL1; 7 | float2 uv : UV; 8 | }; 9 | 10 | struct PS_INPUT 11 | { 12 | float4 pos : SV_POSITION; 13 | float4 col0 : COLOR0; 14 | float4 col1 : COLOR1; 15 | float3 uv : TEXCOORD0; 16 | }; 17 | 18 | 19 | // W/perspective is done in PS ... 20 | PS_INPUT VS( VS_INPUT vi ) 21 | { 22 | PS_INPUT vo = (PS_INPUT)0; 23 | vo.pos.xyz = vi.pos; 24 | 25 | 26 | vo.pos.xy+=float2(-320,-240); 27 | vo.pos.xy/=float2(320,-240); 28 | 29 | vo.col0=vi.col0*vi.pos.z; 30 | vo.col1=vi.col1*vi.pos.z; 31 | vo.uv.xy=vi.uv*vi.pos.z; 32 | vo.uv.z=vo.pos.z; 33 | 34 | vo.pos.z/=65536; 35 | vo.pos.w=1; 36 | 37 | return vo; 38 | } 39 | 40 | 41 | float4 PS( PS_INPUT s) : SV_Target 42 | { 43 | 44 | return s.col0/s.uv.z; 45 | } -------------------------------------------------------------------------------- /nulldc/plugins/drkPvr/d3dRend.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "drkPvr.h" 3 | #include "renderer_if.h" 4 | 5 | #if REND_API == REND_D3D 6 | 7 | bool InitRenderer(); 8 | void TermRenderer(); 9 | void ResetRenderer(bool Manual); 10 | 11 | void HandleEvent(u32 evid,void* p); 12 | bool ThreadStart(); 13 | void ThreadEnd(); 14 | void VBlank(); 15 | void StartRender(); 16 | void EndRender(); 17 | 18 | void ListCont(); 19 | void ListInit(); 20 | void SoftReset(); 21 | 22 | void SetRenderRect(float* rect,bool drc); 23 | void SetFBScale(float x,float y); 24 | void ListModes(void(* callback)(u32 w,u32 h,u32 rr)); 25 | 26 | void VramLockedWrite(vram_block* bl); 27 | 28 | #define rend_init InitRenderer 29 | #define rend_term TermRenderer 30 | #define rend_reset ResetRenderer 31 | 32 | #define rend_thread_start ThreadStart 33 | #define rend_thread_end ThreadEnd 34 | #define rend_vblank VBlank 35 | #define rend_start_render StartRender 36 | #define rend_end_render EndRender 37 | #define rend_handle_event HandleEvent 38 | 39 | #define rend_list_cont ListCont 40 | #define rend_list_init ListInit 41 | #define rend_list_srst SoftReset 42 | 43 | #define rend_text_invl VramLockedWrite 44 | #define rend_set_render_rect SetRenderRect 45 | #define rend_set_fb_scale SetFBScale 46 | #define rend_list_modes ListModes 47 | #endif -------------------------------------------------------------------------------- /nulldc/plugins/drkPvr/d3dRend11.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "drkPvr.h" 3 | #include "renderer_if.h" 4 | 5 | #if REND_API == REND_D3D11 6 | 7 | bool InitRenderer(); 8 | void TermRenderer(); 9 | void ResetRenderer(bool Manual); 10 | 11 | void HandleEvent(u32 evid,void* p); 12 | bool ThreadStart(); 13 | void ThreadEnd(); 14 | void VBlank(); 15 | void StartRender(); 16 | void EndRender(); 17 | 18 | void ListCont(); 19 | void ListInit(); 20 | void SoftReset(); 21 | 22 | void SetRenderRect(float* rect,bool drc); 23 | void SetFBScale(float x,float y); 24 | void ListModes(void(* callback)(u32 w,u32 h,u32 rr)); 25 | 26 | void VramLockedWrite(vram_block* bl); 27 | 28 | #define rend_init InitRenderer 29 | #define rend_term TermRenderer 30 | #define rend_reset ResetRenderer 31 | 32 | #define rend_thread_start ThreadStart 33 | #define rend_thread_end ThreadEnd 34 | #define rend_vblank VBlank 35 | #define rend_start_render StartRender 36 | #define rend_end_render EndRender 37 | #define rend_handle_event HandleEvent 38 | 39 | #define rend_list_cont ListCont 40 | #define rend_list_init ListInit 41 | #define rend_list_srst SoftReset 42 | 43 | #define rend_text_invl VramLockedWrite 44 | #define rend_set_render_rect SetRenderRect 45 | #define rend_set_fb_scale SetFBScale 46 | #define rend_list_modes ListModes 47 | #endif -------------------------------------------------------------------------------- /nulldc/plugins/drkPvr/exports.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | dcGetInterface -------------------------------------------------------------------------------- /nulldc/plugins/drkPvr/helper_classes.cpp: -------------------------------------------------------------------------------- 1 | #include "drkpvr.h" 2 | #include "helper_classes.h" 3 | 4 | u8* buffer_pool[(64*1024*1024)/ChunkSize]; 5 | u32 buffer_pool_count; 6 | 7 | u8* GetBuffer() 8 | { 9 | if (buffer_pool_count!=0) 10 | { 11 | u8* rv=buffer_pool[--buffer_pool_count]; 12 | //VirtualLock(rv,ChunkSize); 13 | return rv; 14 | } 15 | else 16 | { 17 | u8* ptr=(u8*)VirtualAlloc(0,ChunkSize/*+8192*/,MEM_RESERVE | MEM_COMMIT,PAGE_READWRITE); 18 | /*DWORD old; 19 | VirtualProtect(ptr,4096,PAGE_NOACCESS,&old); 20 | VirtualProtect(&ptr[ChunkSize+4096],4096,PAGE_NOACCESS,&old);*/ 21 | 22 | //VirtualAlloc(ptr,ChunkSize,MEM_RESET,PAGE_READWRITE); 23 | //VirtualLock(ptr,ChunkSize); 24 | return ptr /*+4096*/; 25 | } 26 | } 27 | 28 | void FreeBuffer(u8* buffer) 29 | { 30 | if (buffer_pool_count!=1024) 31 | { 32 | //VirtualUnlock(buffer,ChunkSize); 33 | //VirtualAlloc(buffer,ChunkSize,MEM_RESET,PAGE_READWRITE); 34 | buffer_pool[buffer_pool_count++]=buffer; 35 | } 36 | else 37 | { 38 | VirtualFree(buffer/*-4096*/,0,MEM_RELEASE); 39 | } 40 | } -------------------------------------------------------------------------------- /nulldc/plugins/drkPvr/nullRend.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "drkPvr.h" 3 | #include "renderer_if.h" 4 | 5 | #if REND_API == REND_SW 6 | namespace SWRenderer 7 | { 8 | 9 | bool InitRenderer(); 10 | void TermRenderer(); 11 | void ResetRenderer(bool Manual); 12 | 13 | bool ThreadStart(); 14 | void ThreadEnd(); 15 | void VBlank(); 16 | void StartRender(); 17 | void EndRender(); 18 | 19 | void ListCont(); 20 | void ListInit(); 21 | void SoftReset(); 22 | 23 | void SetFpsText(wchar* text); 24 | 25 | void VramLockedWrite(vram_block* bl); 26 | }; 27 | #define rend_init SWRenderer::InitRenderer 28 | #define rend_term SWRenderer::TermRenderer 29 | #define rend_reset SWRenderer::ResetRenderer 30 | 31 | #define rend_thread_start SWRenderer::ThreadStart 32 | #define rend_thread_end SWRenderer::ThreadEnd 33 | #define rend_vblank SWRenderer::VBlank 34 | #define rend_start_render SWRenderer::StartRender 35 | #define rend_end_render SWRenderer::EndRender 36 | 37 | #define rend_list_cont SWRenderer::ListCont 38 | #define rend_list_init SWRenderer::ListInit 39 | #define rend_list_srst SWRenderer::SoftReset 40 | 41 | #define rend_text_invl SWRenderer::VramLockedWrite 42 | #define rend_set_fps_text SWRenderer::SetFpsText 43 | #define rend_set_render_rect(rect) 44 | #define rend_set_fb_scale(rect) 45 | #define rend_list_modes(rect) 46 | #define rend_handle_event(rect) 47 | 48 | #endif 49 | #if REND_API == REND_NONE 50 | namespace NORenderer 51 | { 52 | 53 | bool InitRenderer(); 54 | void TermRenderer(); 55 | void ResetRenderer(bool Manual); 56 | 57 | bool ThreadStart(); 58 | void ThreadEnd(); 59 | void VBlank(); 60 | void StartRender(); 61 | void EndRender(); 62 | 63 | void ListCont(); 64 | void ListInit(); 65 | void SoftReset(); 66 | 67 | void SetFpsText(char* text); 68 | 69 | void VramLockedWrite(vram_block* bl); 70 | }; 71 | #define rend_init NORenderer::InitRenderer 72 | #define rend_term NORenderer::TermRenderer 73 | #define rend_reset NORenderer::ResetRenderer 74 | 75 | #define rend_thread_start NORenderer::ThreadStart 76 | #define rend_thread_end NORenderer::ThreadEnd 77 | #define rend_vblank NORenderer::VBlank 78 | #define rend_start_render NORenderer::StartRender 79 | #define rend_end_render NORenderer::EndRender 80 | 81 | #define rend_list_cont NORenderer::ListCont 82 | #define rend_list_init NORenderer::ListInit 83 | #define rend_list_srst NORenderer::SoftReset 84 | 85 | #define rend_text_invl NORenderer::VramLockedWrite 86 | #define rend_set_fps_text NORenderer::SetFpsText 87 | #define rend_set_render_rect(rect) 88 | #define rend_set_fb_scale(x,y) 89 | #endif -------------------------------------------------------------------------------- /nulldc/plugins/drkPvr/regs.cpp: -------------------------------------------------------------------------------- 1 | #include "regs.h" 2 | #include "renderer_if.h" 3 | #include "ta.h" 4 | #include "spg.h" 5 | 6 | 7 | //seems to work allright .. ;P 8 | //many things need to be emulated , especialy to support lle emulation but for now that's not needed 9 | u8 regs[RegSize]; 10 | 11 | u32 FASTCALL ReadPvrRegister(u32 addr,u32 size) 12 | { 13 | if (size!=4) 14 | { 15 | //error 16 | return 0; 17 | } 18 | 19 | return PvrReg(addr,u32); 20 | } 21 | 22 | void PrintfInfo(); 23 | void FASTCALL WritePvrRegister(u32 paddr,u32 data,u32 size) 24 | { 25 | if (size!=4) 26 | { 27 | //error 28 | return; 29 | } 30 | u32 addr=paddr&RegMask; 31 | 32 | if (addr==ID_addr) 33 | return;//read olny 34 | if (addr==REVISION_addr) 35 | return;//read olny 36 | 37 | if (addr==STARTRENDER_addr) 38 | { 39 | //start render 40 | rend_start_render(); 41 | //PrintfInfo(); 42 | //TODO : fix that mess -- now uses hacksync ;) later will be async too :P:P 43 | 44 | //RaiseInterrupt(InterruptID::holly_RENDER_DONE); 45 | //RaiseInterrupt(InterruptID::holly_RENDER_DONE_isp); 46 | //RaiseInterrupt(InterruptID::holly_RENDER_DONE_vd); 47 | render_end_pending=true; 48 | return; 49 | } 50 | 51 | if (addr==TA_LIST_INIT_addr) 52 | { 53 | if (data>>31) 54 | { 55 | rend_list_init(); 56 | data=0; 57 | } 58 | } 59 | 60 | if (addr==SOFTRESET_addr) 61 | { 62 | if (data!=0) 63 | { 64 | if (data&1) 65 | rend_list_srst(); 66 | data=0; 67 | } 68 | } 69 | 70 | if (addr==TA_LIST_CONT_addr) 71 | { 72 | //a write of anything works ? 73 | rend_list_cont(); 74 | } 75 | 76 | if (addr == FB_R_CTRL_addr || 77 | addr == SPG_CONTROL_addr || 78 | addr == SPG_LOAD_addr) 79 | { 80 | PvrReg(addr,u32)=data; 81 | CalculateSync(); 82 | return; 83 | } 84 | 85 | if (addr>=PALETTE_RAM_START_addr) 86 | { 87 | if (PvrReg(addr,u32)!=data) 88 | { 89 | u32 pal=addr&1023; 90 | 91 | pal_needs_update=true; 92 | _pal_rev_256[pal>>8]++; 93 | _pal_rev_16[pal>>4]++; 94 | } 95 | } 96 | PvrReg(addr,u32)=data; 97 | } 98 | 99 | bool Regs_Init() 100 | { 101 | return true; 102 | } 103 | 104 | void Regs_Term() 105 | { 106 | } 107 | 108 | void Regs_Reset(bool Manual) 109 | { 110 | ID = 0x17FD11DB; 111 | REVISION = 0x00000011; 112 | SOFTRESET = 0x00000007; 113 | SPG_HBLANK_INT.full = 0x031D0000; 114 | SPG_VBLANK_INT.full = 0x01500104; 115 | FPU_PARAM_CFG = 0x0007DF77; 116 | HALF_OFFSET = 0x00000007; 117 | ISP_FEED_CFG = 0x00402000; 118 | SDRAM_REFRESH = 0x00000020; 119 | SDRAM_ARB_CFG = 0x0000001F; 120 | SDRAM_CFG = 0x15F28997; 121 | SPG_HBLANK.full = 0x007E0345; 122 | SPG_LOAD.full = 0x01060359; 123 | SPG_VBLANK.full = 0x01500104; 124 | SPG_WIDTH.full = 0x07F1933F; 125 | VO_CONTROL.full = 0x00000108; 126 | VO_STARTX.full = 0x0000009D; 127 | VO_STARTY.full = 0x00000015; 128 | SCALER_CTL.full = 0x00000400; 129 | FB_BURSTCTRL = 0x00090639; 130 | PT_ALPHA_REF = 0x000000FF; 131 | } -------------------------------------------------------------------------------- /nulldc/plugins/drkPvr/spg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "drkPvr.h" 3 | 4 | bool spg_Init(); 5 | void spg_Term(); 6 | void spg_Reset(bool Manual); 7 | 8 | //#define Frame_Cycles (DCclock/60) 9 | 10 | //need to replace 511 with correct value 11 | //#define Line_Cycles (Frame_Cycles/511) 12 | 13 | void FASTCALL spgUpdatePvr(u32 cycles); 14 | bool spg_Init(); 15 | void spg_Term(); 16 | void spg_Reset(bool Manual); 17 | void CalculateSync(); -------------------------------------------------------------------------------- /nulldc/plugins/drkPvr/ta.cpp: -------------------------------------------------------------------------------- 1 | #include "ta.h" 2 | //Tile Accelerator state machine 3 | #include 4 | 5 | 6 | namespace TASplitter 7 | { 8 | //Splitter function (normaly ta_dma_main , modified for split dma's) 9 | TaListFP* TaCmd; 10 | 11 | void FASTCALL SQ(u32* data) 12 | { 13 | verify(TaCmd!=0); 14 | Ta_Dma* t=(Ta_Dma*)data; 15 | TaCmd(t,t); 16 | } 17 | void FASTCALL Dma(u32* data,u32 size) 18 | { 19 | verify(TaCmd!=0); 20 | Ta_Dma* ta_data=(Ta_Dma*)data; 21 | Ta_Dma* ta_data_end=ta_data+size-1; 22 | 23 | do 24 | { 25 | ta_data =TaCmd(ta_data,ta_data_end); 26 | } 27 | while(ta_data<=ta_data_end); 28 | } 29 | 30 | //DMA from emulator :) 31 | 32 | void TA_ListCont() 33 | { 34 | 35 | } 36 | void TA_ListInit() 37 | { 38 | 39 | } 40 | void TA_SoftReset() 41 | { 42 | 43 | } 44 | } -------------------------------------------------------------------------------- /nulldc/plugins/drkPvr/ta_const_df.h: -------------------------------------------------------------------------------- 1 | ///this file is here to make up for C++'s limitations 2 | static TaListFP* ta_poly_data_lut[15] = 3 | { 4 | ta_poly_data<0,SZ32>, 5 | ta_poly_data<1,SZ32>, 6 | ta_poly_data<2,SZ32>, 7 | ta_poly_data<3,SZ32>, 8 | ta_poly_data<4,SZ32>, 9 | ta_poly_data<5,SZ64>, 10 | ta_poly_data<6,SZ64>, 11 | ta_poly_data<7,SZ32>, 12 | ta_poly_data<8,SZ32>, 13 | ta_poly_data<9,SZ32>, 14 | ta_poly_data<10,SZ32>, 15 | ta_poly_data<11,SZ64>, 16 | ta_poly_data<12,SZ64>, 17 | ta_poly_data<13,SZ64>, 18 | ta_poly_data<14,SZ64>, 19 | }; 20 | //32/64b , full 21 | static TaPolyParamFP* ta_poly_param_lut[5]= 22 | { 23 | (TaPolyParamFP*)TA_decoder::AppendPolyParam0, 24 | (TaPolyParamFP*)TA_decoder::AppendPolyParam1, 25 | (TaPolyParamFP*)AppendPolyParam2Full, 26 | (TaPolyParamFP*)TA_decoder::AppendPolyParam3, 27 | (TaPolyParamFP*)AppendPolyParam4Full 28 | }; 29 | //64b , first part 30 | static TaPolyParamFP* ta_poly_param_a_lut[5]= 31 | { 32 | (TaPolyParamFP*)0, 33 | (TaPolyParamFP*)0, 34 | (TaPolyParamFP*)TA_decoder::AppendPolyParam2A, 35 | (TaPolyParamFP*)0, 36 | (TaPolyParamFP*)TA_decoder::AppendPolyParam4A 37 | }; 38 | 39 | //64b , , second part 40 | static TaListFP* ta_poly_param_b_lut[5]= 41 | { 42 | (TaListFP*)0, 43 | (TaListFP*)0, 44 | (TaListFP*)ta_poly_B_32<2>, 45 | (TaListFP*)0, 46 | (TaListFP*)ta_poly_B_32<4> 47 | }; 48 | -------------------------------------------------------------------------------- /nulldc/plugins/gpARM/aica.cpp: -------------------------------------------------------------------------------- 1 | #include "aica.h" 2 | #include 3 | 4 | 5 | 6 | 7 | //Mainloop 8 | void FASTCALL UpdateARM(u32 Cycles) 9 | { 10 | } 11 | -------------------------------------------------------------------------------- /nulldc/plugins/gpARM/exports.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | dcGetInterface -------------------------------------------------------------------------------- /nulldc/plugins/gpARM/gpARM.cpp: -------------------------------------------------------------------------------- 1 | // nullAICA.cpp : Defines the entry point for the DLL application. 2 | // 3 | 4 | #include "aica.h" 5 | #include 6 | 7 | arm_init_params arm_params; 8 | emu_info eminf; 9 | HINSTANCE hinst; 10 | BOOL APIENTRY DllMain( HMODULE hModule, 11 | DWORD ul_reason_for_call, 12 | LPVOID lpReserved 13 | ) 14 | { 15 | hinst=(HINSTANCE)hModule; 16 | return TRUE; 17 | } 18 | void EXPORT_CALL handle_About(u32 id,void* w,void* p) 19 | { 20 | MessageBoxA((HWND)w,"Made by Exophase\r\nPorted by the nullDC Team","About the gpSP Core...",MB_ICONINFORMATION); 21 | } 22 | s32 FASTCALL OnLoad(emu_info* em) 23 | { 24 | memcpy(&eminf,em,sizeof(eminf)); 25 | 26 | LoadSettings(); 27 | eminf.AddMenuItem(em->RootMenu,-1,L"About",handle_About,0); 28 | return rv_ok; 29 | } 30 | 31 | void FASTCALL OnUnload() 32 | { 33 | } 34 | 35 | //called when plugin is used by emu (you should do first time init here) 36 | s32 FASTCALL Init(arm_init_params* initp) 37 | { 38 | memcpy(&arm_params,initp,sizeof(arm_params)); 39 | 40 | init_mem(); 41 | arm_Init(); 42 | 43 | return rv_ok; 44 | } 45 | 46 | //called when plugin is unloaded by emu , olny if dcInit is called (eg , not called to enumerate plugins) 47 | void FASTCALL Term() 48 | { 49 | term_mem(); 50 | //arm7_Term ? 51 | } 52 | 53 | //It's suposed to reset anything 54 | void FASTCALL Reset(bool Manual) 55 | { 56 | arm_Reset(); 57 | } 58 | 59 | void FASTCALL SetResetState(u32 state) 60 | { 61 | arm_SetEnabled(state==0); 62 | } 63 | //Give to the emu pointers for the PowerVR interface 64 | EXPORT void EXPORT_CALL dcGetInterface(plugin_interface* info) 65 | { 66 | info->InterfaceVersion=PLUGIN_I_F_VERSION; 67 | 68 | #define c info->common 69 | #define a info->arm 70 | 71 | wcscpy(c.Name,L"VBA ARM Sound Cpu Core [" _T(__DATE__) L"]"); 72 | 73 | c.InterfaceVersion=ARM_PLUGIN_I_F_VERSION; 74 | c.Type=Plugin_ARM; 75 | 76 | c.Load=OnLoad; 77 | c.Unload=OnUnload; 78 | 79 | a.Init=Init; 80 | a.Reset=Reset; 81 | a.Term=Term; 82 | 83 | a.Update=UpdateARM; 84 | a.ArmInterruptChange=ArmInterruptChange; 85 | a.ExeptionHanlder=0; 86 | a.SetResetState=SetResetState; 87 | } 88 | 89 | int cfgGetInt(char* key,int def) 90 | { 91 | wchar t[512]; 92 | mbstowcs(t,key,512); 93 | return eminf.ConfigLoadInt(L"nullAica",t,def); 94 | } 95 | void cfgSetInt(char* key,int def) 96 | { 97 | wchar t[512]; 98 | mbstowcs(t,key,512); 99 | eminf.ConfigSaveInt(L"nullAica",t,def); 100 | } 101 | 102 | void LoadSettings() 103 | { 104 | //load default settings before init 105 | //settings.BufferSize=cfgGetInt("BufferSize",1024); 106 | } 107 | 108 | void SaveSettings() 109 | { 110 | 111 | } -------------------------------------------------------------------------------- /nulldc/plugins/gpARM/x86/Makefile: -------------------------------------------------------------------------------- 1 | # gpSP makefile 2 | # Gilead Kutnick - Exophase 3 | 4 | # Global definitions 5 | 6 | CC = gcc 7 | STRIP = strip 8 | AS = as 9 | 10 | PREFIX = /usr 11 | OBJS = main.o cpu.o memory.o video.o input.o sound.o \ 12 | cpu_threaded.o gui.o x86_stub.o cheats.o zip.o 13 | BIN = gpsp.exe 14 | 15 | # Platform specific definitions 16 | 17 | VPATH += .. 18 | CFLAGS += 19 | INCLUDES = -I${PREFIX}/include `sdl-config --cflags` 20 | LIBS = -L${PREFIX}/lib `sdl-config --libs` -mconsole -lz 21 | 22 | # Compilation: 23 | 24 | .SUFFIXES: .c .S 25 | 26 | %.o: %.c 27 | ${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $< 28 | 29 | %.o: %.S 30 | ${AS} -o $@ $< 31 | 32 | all: ${OBJS} 33 | ${CC} ${OBJS} ${LIBS} -o ${BIN} 34 | ${STRIP} ${BIN} 35 | 36 | clean: 37 | rm -f *.o ${BIN} 38 | 39 | -------------------------------------------------------------------------------- /nulldc/plugins/mudPvr/exports.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | dcGetInterface -------------------------------------------------------------------------------- /nulldc/plugins/mudPvr/mudpvr.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mudpvr", "mudpvr.vcxproj", "{29CACA55-8B48-4A38-8D28-1005E22F8A1F}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {29CACA55-8B48-4A38-8D28-1005E22F8A1F}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {29CACA55-8B48-4A38-8D28-1005E22F8A1F}.Debug|Win32.Build.0 = Debug|Win32 14 | {29CACA55-8B48-4A38-8D28-1005E22F8A1F}.Release|Win32.ActiveCfg = Release|Win32 15 | {29CACA55-8B48-4A38-8D28-1005E22F8A1F}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /nulldc/plugins/mudPvr/mudpvr.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skmp/nullDC-v1/1611c3cf0aa2755611455aa7a02b4f62babee7bd/nulldc/plugins/mudPvr/mudpvr.suo -------------------------------------------------------------------------------- /nulldc/plugins/mudPvr/src/TexCache.cpp: -------------------------------------------------------------------------------- 1 | #include "TexCache.h" 2 | #include "regs.h" 3 | 4 | u32 detwiddle[2][8][1024]; 5 | //input : address in the yyyyyxxxxx format 6 | //output : address in the xyxyxyxy format 7 | //U : x resolution , V : y resolution 8 | //twidle works on 64b words 9 | u32 fastcall twiddle_fast(u32 x,u32 y,u32 bcx,u32 bcy) 10 | { 11 | return detwiddle[0][bcy][x]+detwiddle[1][bcx][y]; 12 | } 13 | 14 | u32 fastcall twiddle_razi_(u32 x,u32 y,u32 x_sz,u32 y_sz) 15 | { 16 | u32 rv=0;//low 2 bits are directly passed -> needs some misc stuff to work.However 17 | //Pvr internaly maps the 64b banks "as if" they were twidled :p 18 | 19 | u32 sh=0; 20 | x_sz>>=1; 21 | y_sz>>=1; 22 | while(x_sz!=0 || y_sz!=0) 23 | { 24 | if (y_sz) 25 | { 26 | u32 temp=y&1; 27 | rv|=temp<>=1; 30 | y>>=1; 31 | sh++; 32 | } 33 | if (x_sz) 34 | { 35 | u32 temp=x&1; 36 | rv|=temp<>=1; 39 | x>>=1; 40 | sh++; 41 | } 42 | } 43 | return rv; 44 | } 45 | void BuildTwiddleTables() 46 | { 47 | for (u32 s=0;s<8;s++) 48 | { 49 | u32 x_sz=1024; 50 | u32 y_sz=8< 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | int msgboxf(wchar* text,unsigned int type,...); 15 | 16 | 17 | #define BUILD 0 18 | #define MINOR 1 19 | #define MAJOR 0 20 | #define DCclock (200*1000*1000) 21 | 22 | extern bool render_end_pending; 23 | extern u32 render_end_pending_cycles; 24 | extern pvr_init_params params; 25 | 26 | float GetSeconds(); 27 | #define dbgbreak __debugbreak() 28 | 29 | #define fastcall __fastcall 30 | 31 | #if DO_VERIFY==OP_ON 32 | #define verify(x) if((x)==false){ static bool d_msg=true; if (d_msg) { d_msg = msgboxf(L"Verify Failed : " _T(#x) L"\n in %s -> %s : %d \nWant to report this error again ?",MB_ICONERROR|MB_YESNO,_T(__FUNCTION__),_T(__FILE__),__LINE__)==IDYES?true:false;} if (d_msg){ dbgbreak;}} 33 | #define verifyf(x) if((x)==false){ msgboxf(L"Verify Failed : " _T(#x) L"\n in %s -> %s : %d \n",MB_ICONERROR,_T(__FUNCTION__),_T(__FILE__),__LINE__); dbgbreak;} 34 | #define verifyc(x) {HRESULT hrr=(x); if(FAILED(hrr)){ msgboxf(L"Verify Failed : " _T(#x) L"\n in %s -> %s : %d HR=0x%08X\n",MB_ICONERROR,_T(__FUNCTION__),_T(__FILE__),__LINE__,hrr); dbgbreak;} } 35 | #else 36 | #define verify(x) 37 | #define verifyf(x) (x) 38 | #define verifyc(x) (x) 39 | #endif 40 | 41 | #define die(reason) { printf("Fatal error : " #reason "\n in %s -> %s : %d \n",__FUNCTION__,__FILE__,__LINE__); dbgbreak;} 42 | #define fverify verify 43 | 44 | #define log0(xx) printf(xx " (from "__FUNCTION__ ")\n"); 45 | #define log1(xx,yy) printf(xx " (from "__FUNCTION__ ")\n",yy); 46 | #define log2(xx,yy,zz) printf(xx " (from "__FUNCTION__ ")\n",yy,zz); 47 | #define log3(xx,yy,gg) printf(xx " (from "__FUNCTION__ ")\n",yy,zz,gg); -------------------------------------------------------------------------------- /nulldc/plugins/mudPvr/src/pvr_impl.h: -------------------------------------------------------------------------------- 1 | #ifndef _PVR_IMP_H_ 2 | #define _PVR_IMP_H_ 3 | 4 | #include "mudpvr.h" 5 | #include "pvr_renderer_d3d1x.h" 6 | 7 | bool spg_Init(); 8 | void spg_Term(); 9 | void spg_Reset(bool Manual); 10 | void _fastcall spgUpdatePvr(u32 cycles); 11 | bool spg_Init(); 12 | void spg_Term(); 13 | void spg_Reset(bool Manual); 14 | void CalculateSync(); 15 | u32 FASTCALL ReadPvrRegister(u32 addr,u32 size); 16 | void FASTCALL WritePvrRegister(u32 paddr,u32 data,u32 size); 17 | bool Regs_Init(); 18 | void Regs_Term(); 19 | void Regs_Reset(bool Manual); 20 | 21 | #endif -------------------------------------------------------------------------------- /nulldc/plugins/mudPvr/src/pvr_renderer_d3d1x.h: -------------------------------------------------------------------------------- 1 | #ifndef _PVR_RENDERER_H_ 2 | #define _PVR_RENDERER_H_ 3 | 4 | #include "mudpvr.h" 5 | 6 | bool rend_init(); 7 | void rend_term(); 8 | void rend_reset(bool Manual); 9 | bool rend_thread_start(); 10 | void rend_thread_end (); 11 | void rend_vblank (); 12 | void rend_start_render (); 13 | void rend_end_render (); 14 | void rend_handle_event (u32 evid,void* p); 15 | 16 | void rend_list_cont(); 17 | void rend_list_init(); 18 | void rend_list_softreset(); 19 | 20 | void rend_text_invl (vram_block* bl); 21 | void rend_set_render_rect (float* rect,bool drc); 22 | void rend_set_fb_scale (float x,float y); 23 | void rend_list_modes(void(* callback)(u32 w,u32 h,u32 rr)); 24 | 25 | #endif -------------------------------------------------------------------------------- /nulldc/plugins/mudPvr/src/ta.cpp: -------------------------------------------------------------------------------- 1 | #include "ta.h" 2 | //Tile Accelerator state machine 3 | #include 4 | 5 | 6 | namespace TASplitter 7 | { 8 | //Splitter function (normaly ta_dma_main , modified for split dma's) 9 | TaListFP* TaCmd; 10 | 11 | void FASTCALL SQ(u32* data) 12 | { 13 | verify(TaCmd!=0); 14 | Ta_Dma* t=(Ta_Dma*)data; 15 | TaCmd(t,t); 16 | } 17 | void FASTCALL Dma(u32* data,u32 size) 18 | { 19 | verify(TaCmd!=0); 20 | Ta_Dma* ta_data=(Ta_Dma*)data; 21 | Ta_Dma* ta_data_end=ta_data+size-1; 22 | 23 | do 24 | { 25 | ta_data =TaCmd(ta_data,ta_data_end); 26 | } 27 | while(ta_data<=ta_data_end); 28 | } 29 | 30 | //DMA from emulator :) 31 | 32 | void TA_ListCont() 33 | { 34 | 35 | } 36 | void TA_ListInit() 37 | { 38 | 39 | } 40 | void TA_SoftReset() 41 | { 42 | 43 | } 44 | } -------------------------------------------------------------------------------- /nulldc/plugins/mudPvr/src/ta_const_df.h: -------------------------------------------------------------------------------- 1 | ///this file is here to make up for C++'s limitations 2 | static TaListFP* ta_poly_data_lut[15] = 3 | { 4 | ta_poly_data<0,SZ32>, 5 | ta_poly_data<1,SZ32>, 6 | ta_poly_data<2,SZ32>, 7 | ta_poly_data<3,SZ32>, 8 | ta_poly_data<4,SZ32>, 9 | ta_poly_data<5,SZ64>, 10 | ta_poly_data<6,SZ64>, 11 | ta_poly_data<7,SZ32>, 12 | ta_poly_data<8,SZ32>, 13 | ta_poly_data<9,SZ32>, 14 | ta_poly_data<10,SZ32>, 15 | ta_poly_data<11,SZ64>, 16 | ta_poly_data<12,SZ64>, 17 | ta_poly_data<13,SZ64>, 18 | ta_poly_data<14,SZ64>, 19 | }; 20 | //32/64b , full 21 | static TaPolyParamFP* ta_poly_param_lut[5]= 22 | { 23 | (TaPolyParamFP*)TA_decoder::AppendPolyParam0, 24 | (TaPolyParamFP*)TA_decoder::AppendPolyParam1, 25 | (TaPolyParamFP*)AppendPolyParam2Full, 26 | (TaPolyParamFP*)TA_decoder::AppendPolyParam3, 27 | (TaPolyParamFP*)AppendPolyParam4Full 28 | }; 29 | //64b , first part 30 | static TaPolyParamFP* ta_poly_param_a_lut[5]= 31 | { 32 | (TaPolyParamFP*)0, 33 | (TaPolyParamFP*)0, 34 | (TaPolyParamFP*)TA_decoder::AppendPolyParam2A, 35 | (TaPolyParamFP*)0, 36 | (TaPolyParamFP*)TA_decoder::AppendPolyParam4A 37 | }; 38 | 39 | //64b , , second part 40 | static TaListFP* ta_poly_param_b_lut[5]= 41 | { 42 | (TaListFP*)0, 43 | (TaListFP*)0, 44 | (TaListFP*)ta_poly_B_32<2>, 45 | (TaListFP*)0, 46 | (TaListFP*)ta_poly_B_32<4> 47 | }; 48 | -------------------------------------------------------------------------------- /nulldc/plugins/nullAICA/ReadMe.txt: -------------------------------------------------------------------------------- 1 | --nullDC AICA plugin-- 2 | 3 | Basic emulation of aica: 4 | 5 | --Chanel 6 | All stream types implemented 7 | Loop implemented 8 | Pitch implemented 9 | AEG not implemented 10 | FEG not implemented 11 | ALFO not implemented 12 | PLFO not implemented 13 | 14 | --Misc 15 | Timers implemented 16 | e68k implemented , needs check vs real hardware 17 | AICA interrupt controller implemented 18 | DSP not implemented 19 | 20 | 21 | 22 | Aica is a powerfull audio generator: 23 | 64 chanels , spcm8/16,yapdcm/s,noise as input , with PAN/VOL settings with each chanel 24 | 16 channel - 128 step dsp w/ ring buffer (thats ~ 5.6M steps/second !) 25 | 16 or 18 bit DAC (selectable) 26 | 27 | The output of each chanel are merged to the DSP input regs w/ volume control , and to the final mix regs , we/ pan and volume control 28 | The output of each dsp chanel are merged w/ to the final mix regs w/ pan & volume control 29 | The EXTS0 channels (2 , l/r , cdda) are merged to the final mix regs w/ pan & volume control 30 | 31 | 32 | -------------------------------------------------------------------------------- /nulldc/plugins/nullAICA/audiostream.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "nullAICA.h" 3 | 4 | void WriteSample(s16 r, s16 l); 5 | void WriteSamples1(s16* r , s16* l , u32 sample_count); 6 | void WriteSamples2(s16* rl , u32 sample_count); 7 | 8 | void InitAudio(); 9 | void TermAudio(); 10 | 11 | class WaveWriter 12 | { 13 | public: 14 | FILE* f; 15 | WaveWriter(char* file) 16 | { 17 | f=fopen(file,"wb"); 18 | Write("RIFF",4); 19 | Write("NULL",4); //will replaced with file size later on 20 | Write("WAVE",4); 21 | 22 | Write("fmt ",4); 23 | Write32(16); //Chunk size, 16 for pcm 24 | Write16(1); //uncompressed 25 | Write16(2); //2 channels 26 | Write32(44100); //Sample rate 27 | Write32(44100*2*2); //Byte rate 28 | Write16(4); //block aligment 29 | Write16(16); //Bits per sample 30 | 31 | Write("data",4); 32 | Write("NULL",4); //will replaced with file size later on 33 | 34 | } 35 | void Write(void* ptr,u32 sz) 36 | { 37 | fwrite(ptr,1,sz,f); 38 | } 39 | void Write8(u8 l) 40 | { 41 | Write(&l,1); 42 | } 43 | void Write16(u16 l) 44 | { 45 | Write(&l,2); 46 | } 47 | void Write32(u32 l) 48 | { 49 | Write(&l,4); 50 | } 51 | 52 | void Write(s16 l,s16 r) 53 | { 54 | Write(&l,2); 55 | Write(&r,2); 56 | } 57 | ~WaveWriter() 58 | { 59 | int sz=ftell(f); 60 | fseek(f,4,SEEK_SET); 61 | Write32(sz-8); 62 | fseek(f,40,SEEK_SET); 63 | Write32(sz-44); 64 | fclose(f); 65 | } 66 | }; -------------------------------------------------------------------------------- /nulldc/plugins/nullAICA/audiostream_rif.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "nullAICA.h" 3 | 4 | //Get used size in the ring buffer 5 | u32 asRingUsedCount(); 6 | //Get free size in the ring buffer 7 | u32 asRingFreeCount(); 8 | //Read 'Count' samples from the ring buffer.Returns true if successful. 9 | //If sz==0 then a whole buffer is read 10 | bool asRingRead(u8* dst,u32 count=0); 11 | bool asRingStretchRead(u8* dst,u32 sz=0); -------------------------------------------------------------------------------- /nulldc/plugins/nullAICA/config_ui.h: -------------------------------------------------------------------------------- 1 | #include "gui.h" -------------------------------------------------------------------------------- /nulldc/plugins/nullAICA/debugger_ui.cpp: -------------------------------------------------------------------------------- 1 | #include "debugger_ui.h" 2 | INT_PTR CALLBACK DebuggerDlgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) 3 | { 4 | switch( uMsg ) 5 | { 6 | case WM_INITDIALOG: 7 | { 8 | 9 | } 10 | return true; 11 | 12 | case WM_COMMAND: 13 | 14 | switch( LOWORD(wParam) ) 15 | { 16 | case IDOK: 17 | case IDCANCEL: 18 | EndDialog(hWnd,0); 19 | return true; 20 | 21 | default: break; 22 | } 23 | return false; 24 | 25 | case WM_CLOSE: 26 | case WM_DESTROY: 27 | EndDialog(hWnd,0); 28 | return true; 29 | 30 | default: break; 31 | } 32 | 33 | return false; 34 | } 35 | 36 | 37 | void ShowDebugger(HWND parent) 38 | { 39 | DialogBox(hinst,MAKEINTRESOURCE(IDD_DEBUGGER),parent,DebuggerDlgProc); 40 | } -------------------------------------------------------------------------------- /nulldc/plugins/nullAICA/debugger_ui.h: -------------------------------------------------------------------------------- 1 | #include "gui.h" -------------------------------------------------------------------------------- /nulldc/plugins/nullAICA/ds_audiostream.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "nullAICA.h" 3 | 4 | void ds_InitAudio(); 5 | void ds_TermAudio(); 6 | 7 | void ds2_InitAudio(); 8 | void ds2_TermAudio(); -------------------------------------------------------------------------------- /nulldc/plugins/nullAICA/dsp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "aica.h" 3 | 4 | struct dsp_t 5 | { 6 | //Dynarec 7 | u8 DynCode[4096*8]; //32 kb, 8 pages 8 | 9 | //buffered DSP state 10 | //24 bit wide 11 | u32 TEMP[128]; 12 | //24 bit wide 13 | u32 MEMS[32]; 14 | //20 bit wide 15 | s32 MIXS[16]; 16 | 17 | //RBL/RBP (decoded) 18 | u32 RBP; 19 | u32 RBL; 20 | 21 | struct 22 | { 23 | bool MAD_OUT; 24 | bool MEM_ADDR; 25 | bool MEM_RD_DATA; 26 | bool MEM_WT_DATA; 27 | bool FRC_REG; 28 | bool ADRS_REG; 29 | bool Y_REG; 30 | 31 | bool MDEC_CT; 32 | bool MWT_1; 33 | bool MRD_1; 34 | //bool MADRS; 35 | bool MEMS; 36 | bool NOFL_1; 37 | bool NOFL_2; 38 | 39 | bool TEMPS; 40 | bool EFREG; 41 | }regs_init; 42 | 43 | //s32 -> stored as signed extended to 32 bits 44 | struct 45 | { 46 | s32 MAD_OUT; 47 | s32 MEM_ADDR; 48 | s32 MEM_RD_DATA; 49 | s32 MEM_WT_DATA; 50 | s32 FRC_REG; 51 | s32 ADRS_REG; 52 | s32 Y_REG; 53 | 54 | u32 MDEC_CT; 55 | u32 MWT_1; 56 | u32 MRD_1; 57 | u32 MADRS; 58 | u32 NOFL_1; 59 | u32 NOFL_2; 60 | }regs; 61 | //DEC counter :) 62 | u32 DEC; 63 | 64 | //various dsp regs 65 | signed int ACC; //26 bit 66 | signed int SHIFTED; //24 bit 67 | signed int X; //24 bit 68 | signed int Y; //13 bit 69 | signed int B; //26 bit 70 | signed int INPUTS; //24 bit 71 | signed int MEMVAL; 72 | signed int FRC_REG; //13 bit 73 | signed int Y_REG; //24 bit 74 | unsigned int ADDR; 75 | unsigned int ADRS_REG; //13 bit 76 | 77 | //Direct Mapped data : 78 | //COEF *128 79 | //MADRS *64 80 | //MPRO(dsp code) *4 *128 81 | //EFREG *16 82 | //EXTS *2 83 | 84 | 85 | //Dynrec flags 86 | bool dyndirty; 87 | }; 88 | 89 | __declspec(align(4096)) 90 | extern dsp_t dsp; 91 | 92 | void dsp_init(); 93 | void dsp_term(); 94 | void dsp_step(); 95 | void dsp_writenmem(u32 addr); -------------------------------------------------------------------------------- /nulldc/plugins/nullAICA/exports.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | dcGetInterface -------------------------------------------------------------------------------- /nulldc/plugins/nullAICA/gui.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include "nullAICA.h" 3 | #include "resource.h" 4 | extern u32 config_scmi,config_stami,config_stami2; 5 | void ShowConfig(HWND parent); 6 | void ShowDebugger(HWND parent); 7 | void Cofnig_UpdateMenuSelections(); 8 | -------------------------------------------------------------------------------- /nulldc/plugins/nullAICA/mem.cpp: -------------------------------------------------------------------------------- 1 | #include "mem.h" 2 | #include "dsp.h" 3 | #include "sgc_if.h" 4 | 5 | u8 *aica_reg; 6 | u8 *aica_ram; 7 | 8 | //00000000~007FFFFF @DRAM_AREA* 9 | //00800000~008027FF @CHANNEL_DATA 10 | //00802800~00802FFF @COMMON_DATA 11 | //00803000~00807FFF @DSP_DATA 12 | template 13 | u32 ReadReg(u32 addr) 14 | { 15 | if (addr<0x2800) 16 | { 17 | ReadMemArrRet(aica_reg,addr,sz); 18 | } 19 | if (addr < 0x2818) 20 | { 21 | if (sz==1) 22 | { 23 | ReadCommonReg(addr,true); 24 | ReadMemArrRet(aica_reg,addr,1); 25 | } 26 | else 27 | { 28 | ReadCommonReg(addr,false); 29 | //ReadCommonReg8(addr+1); 30 | ReadMemArrRet(aica_reg,addr,2); 31 | } 32 | } 33 | 34 | ReadMemArrRet(aica_reg,addr,sz); 35 | } 36 | template 37 | void WriteReg(u32 addr,u32 data) 38 | { 39 | if (addr < 0x2000) 40 | { 41 | //Channel data 42 | u32 chan=addr>>7; 43 | u32 reg=addr&0x7F; 44 | if (sz==1) 45 | { 46 | WriteMemArr(aica_reg,addr,data,1); 47 | WriteChannelReg8(chan,reg); 48 | } 49 | else 50 | { 51 | WriteMemArr(aica_reg,addr,data,2); 52 | WriteChannelReg8(chan,reg); 53 | WriteChannelReg8(chan,reg+1); 54 | } 55 | return; 56 | } 57 | 58 | if (addr<0x2800) 59 | { 60 | if (sz==1) 61 | { 62 | WriteMemArr(aica_reg,addr,data,1); 63 | } 64 | else 65 | { 66 | WriteMemArr(aica_reg,addr,data,2); 67 | } 68 | return; 69 | } 70 | 71 | if (addr < 0x2818) 72 | { 73 | if (sz==1) 74 | { 75 | WriteCommonReg8(addr,data); 76 | } 77 | else 78 | { 79 | WriteCommonReg8(addr,data&0xFF); 80 | WriteCommonReg8(addr+1,data>>8); 81 | } 82 | return; 83 | } 84 | 85 | if (addr>=0x3000) 86 | { 87 | if (sz==1) 88 | { 89 | WriteMemArr(aica_reg,addr,data,1); 90 | dsp_writenmem(addr); 91 | } 92 | else 93 | { 94 | WriteMemArr(aica_reg,addr,data,2); 95 | dsp_writenmem(addr); 96 | dsp_writenmem(addr+1); 97 | } 98 | } 99 | if (sz==1) 100 | WriteAicaReg<1>(addr,data); 101 | else 102 | WriteAicaReg<2>(addr,data); 103 | } 104 | //Aica reads (both sh4&arm) 105 | u32 FASTCALL aica_ReadMem_reg(u32 addr,u32 size) 106 | { 107 | if (size==1) 108 | return ReadReg<1>(addr & 0x7FFF); 109 | else 110 | return ReadReg<2>(addr & 0x7FFF); 111 | 112 | //must never come here 113 | return 0; 114 | } 115 | 116 | void FASTCALL aica_WriteMem_reg(u32 addr,u32 data,u32 size) 117 | { 118 | if (size==1) 119 | WriteReg<1>(addr & 0x7FFF,data); 120 | else 121 | WriteReg<2>(addr & 0x7FFF,data); 122 | } 123 | 124 | //Map using _vmem .. yay 125 | void init_mem() 126 | { 127 | aica_ram=aica_params.aica_ram; 128 | aica_reg=(u8*)malloc(0x8000); 129 | memset(aica_ram,0,AICA_RAM_SIZE); 130 | memset(aica_reg,0,0x8000); 131 | } 132 | //kill mem map & free used mem ;) 133 | void term_mem() 134 | { 135 | free(aica_reg); 136 | } 137 | 138 | -------------------------------------------------------------------------------- /nulldc/plugins/nullAICA/mem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "aica.h" 3 | 4 | u32 FASTCALL aica_ReadMem_reg(u32 addr,u32 size); 5 | void FASTCALL aica_WriteMem_reg(u32 addr,u32 data,u32 size); 6 | 7 | void init_mem(); 8 | void term_mem(); 9 | 10 | extern u8 *aica_reg; 11 | extern u8 *aica_ram; 12 | #define aica_reg_16 ((u16*)aica_reg) 13 | 14 | #define AICA_RAM_SIZE (ARAM_SIZE) 15 | #define AICA_RAM_MASK (ARAM_MASK) -------------------------------------------------------------------------------- /nulldc/plugins/nullAICA/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by nullAICA.rc 4 | // 5 | #define IDD_SETTINGS 101 6 | #define IDD_DIALOG1 102 7 | #define IDD_DEBUGGER 102 8 | #define IDC_RADIO1 1002 9 | #define IDC_RADIO2 1003 10 | #define IDC_RADIO3 1004 11 | #define IDC_RADIO4 1005 12 | #define IDC_RADIO5 1006 13 | #define IDC_HWMIX 1007 14 | #define IDC_GFOCUS 1009 15 | #define IDC_FSYNC 1010 16 | #define IDC_SLIDER1 1011 17 | #define IDC_RADIO6 1016 18 | #define IDC_RADIO7 1018 19 | 20 | // Next default values for new objects 21 | // 22 | #ifdef APSTUDIO_INVOKED 23 | #ifndef APSTUDIO_READONLY_SYMBOLS 24 | #define _APS_NEXT_RESOURCE_VALUE 103 25 | #define _APS_NEXT_COMMAND_VALUE 40001 26 | #define _APS_NEXT_CONTROL_VALUE 1012 27 | #define _APS_NEXT_SYMED_VALUE 101 28 | #endif 29 | #endif 30 | -------------------------------------------------------------------------------- /nulldc/plugins/nullAICA/sdl_audiostream.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "audiostream_rif.h" 3 | #include "audiostream.h" 4 | 5 | #ifdef _INCLUDE_SDL 6 | #include 7 | #pragma comment(lib, "sdl.lib") 8 | 9 | /* Prototype of our callback function */ 10 | void sdl_fill_audio(void *userdata, Uint8 *stream, int len); 11 | void sdl_InitAudio() 12 | { 13 | SDL_Init(SDL_INIT_AUDIO | SDL_INIT_NOPARACHUTE); 14 | 15 | SDL_AudioSpec desired; 16 | 17 | //44.1k 18 | desired.freq=44100; 19 | //16-bit signed audio 20 | desired.format=AUDIO_S16LSB; 21 | //stereo 22 | desired.channels=2; 23 | //Large audio buffer reduces risk of dropouts but increases response time 24 | desired.samples=settings.BufferSize; 25 | 26 | /* Our callback function */ 27 | desired.callback=sdl_fill_audio; 28 | 29 | desired.userdata=NULL; 30 | 31 | /* Open the audio device */ 32 | if ( SDL_OpenAudio(&desired, 0) < 0 ){ 33 | fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError()); 34 | exit(-1); 35 | } 36 | //sdl_InitAudBuffers(desired.samples); 37 | SDL_PauseAudio(0); 38 | } 39 | void sdl_TermAudio() 40 | { 41 | SDL_PauseAudio(1); 42 | SDL_CloseAudio(); 43 | } 44 | 45 | void sdl_fill_audio(void *userdata, Uint8 *stream, int len) 46 | { 47 | u8* rb=GetReadBuffer(); 48 | speed_limit.Set(); 49 | if (rb) 50 | { 51 | memcpy(stream,rb,len); 52 | } 53 | else 54 | { 55 | memset(stream,0,len); 56 | //printf("SDLAudioStream : out of buffers ...\n"); 57 | } 58 | 59 | //if (len!=settings.BufferSize*4) 60 | // printf("Error [sdl_fill_audio]: len!=buffersz\n"); 61 | } 62 | #endif -------------------------------------------------------------------------------- /nulldc/plugins/nullAICA/sdl_audiostream.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "nullAICA.h" 3 | 4 | #ifdef _INCLUDE_SDL 5 | void sdl_InitAudio(); 6 | void sdl_TermAudio(); 7 | #else 8 | #define sdl_InitAudio ds_InitAudio 9 | #define sdl_TermAudio ds_TermAudio 10 | #endif 11 | -------------------------------------------------------------------------------- /nulldc/plugins/nullAICA/sgc_if.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "aica.h" 3 | 4 | void AICA_Sample(); 5 | 6 | //u32 ReadChannelReg(u32 channel,u32 reg); 7 | void WriteChannelReg8(u32 channel,u32 reg); 8 | 9 | void sgc_Init(); 10 | void sgc_Term(); 11 | 12 | union fp_22_10 13 | { 14 | struct 15 | { 16 | u32 fp:10; 17 | u32 ip:22; 18 | }; 19 | u32 full; 20 | }; 21 | union fp_s_22_10 22 | { 23 | struct 24 | { 25 | u32 fp:10; 26 | s32 ip:22; 27 | }; 28 | s32 full; 29 | }; 30 | union fp_20_12 31 | { 32 | struct 33 | { 34 | u32 fp:12; 35 | u32 ip:20; 36 | }; 37 | u32 full; 38 | }; 39 | 40 | //#define SAMPLE_TYPE_SHIFT (8) 41 | typedef s32 SampleType; 42 | 43 | //Output of the sgc 44 | extern SampleType mixl; 45 | extern SampleType mixr; 46 | 47 | void ReadCommonReg(u32 reg,bool byte); 48 | void WriteCommonReg8(u32 reg,u32 data); 49 | #define clip(x,min,max) if ((x)<(min)) (x)=(min); if ((x)>(max)) (x)=(max); 50 | #define clip16(x) clip(x,-32768,32767) 51 | -------------------------------------------------------------------------------- /nulldc/plugins/nullDC_GUI/CPicture.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | ////////////////// 6 | // Picture object--encapsulates IPicture 7 | // 8 | class CPicture 9 | { 10 | public: 11 | CPicture(); 12 | ~CPicture(); 13 | 14 | // Load frm various sosurces 15 | BOOL Load(HINSTANCE hInst, UINT nIDRes); 16 | BOOL Load(LPCTSTR pszPathName); 17 | BOOL CPicture::Load(HBITMAP hBmp,HPALETTE hPal,bool own=false); 18 | BOOL Load(IStream* pstm); 19 | BOOL Save(const wchar_t* to); 20 | BOOL CPicture::Select(HDC hDC, HDC* newhDC,OLE_HANDLE *hBmp); 21 | // render to device context 22 | BOOL Render(HDC dc, RECT* rc, LPCRECT prcMFBounds=NULL) const; 23 | 24 | SIZE GetImageSize(HDC dc=NULL) const; 25 | 26 | operator IPicture*() { 27 | return m_spIPicture; 28 | } 29 | 30 | void GetHIMETRICSize(OLE_XSIZE_HIMETRIC& cx, OLE_YSIZE_HIMETRIC& cy) const { 31 | cx = cy = 0; 32 | const_cast(this)->m_hr = m_spIPicture->get_Width(&cx); 33 | const_cast(this)->m_hr = m_spIPicture->get_Height(&cy); 34 | } 35 | 36 | void Free() { 37 | if (m_spIPicture) { 38 | m_spIPicture->Release(); 39 | } 40 | m_spIPicture=0; 41 | } 42 | 43 | protected: 44 | 45 | void SetHIMETRICtoDP(HDC hdc, SIZE* sz) const; 46 | 47 | IPicture* m_spIPicture; // ATL smart pointer to IPicture 48 | HBITMAP bmph; 49 | HRESULT m_hr; // last error code 50 | }; 51 | -------------------------------------------------------------------------------- /nulldc/plugins/nullDC_GUI/CtrlMemView.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | ////////////////////////////////////////////////////////////////////////// 4 | //CtrlDisAsmView 5 | // CtrlDisAsmView.cpp 6 | ////////////////////////////////////////////////////////////////////////// 7 | //This Win32 control is made to be flexible and usable with 8 | //every kind of CPU architechture that has fixed width instruction words. 9 | //Just supply it an instance of a class derived from Debugger, with all methods 10 | //overridden for full functionality. 11 | //by henrik 12 | // 13 | //To add to a dialog box, just draw a User Control in the dialog editor, 14 | //and set classname to "CtrlDisAsmView". you also need to call CtrlDisAsmView::init() 15 | //before opening this dialog, to register the window class. 16 | // 17 | //To get a class instance to be able to access it, just use getFrom(HWND wnd). 18 | // 19 | // Copyright by Henrik Rydgard 2003 20 | // This is NOT GPL software. 21 | ////////////////////////////////////////////////////////////////////////// 22 | 23 | #include "DebugInterface.h" 24 | #include "SH4DbgInterface.h" 25 | 26 | void* GetWindowPtr(HWND hWnd,int nIndex); 27 | void SetWindowPtr( HWND hWnd,int nIndex,void* dwNewLong); 28 | 29 | enum MemViewMode 30 | { 31 | MV_NORMAL, 32 | MV_SYMBOLS, 33 | MV_MAX 34 | }; 35 | 36 | class CtrlMemView 37 | { 38 | HWND wnd; 39 | HFONT font; 40 | RECT rect; 41 | 42 | int curAddress; 43 | int align; 44 | int rowHeight; 45 | 46 | int selection; 47 | int oldSelection; 48 | bool selectionChanged; 49 | bool selecting; 50 | bool hasFocus; 51 | static TCHAR szClassName[]; 52 | DebugInterface *debugger; 53 | MemViewMode mode; 54 | public: 55 | CtrlMemView(HWND _wnd); 56 | ~CtrlMemView(); 57 | static void init(); 58 | static void deinit(); 59 | static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); 60 | static CtrlMemView * getFrom(HWND wnd); 61 | 62 | void setDebugger(DebugInterface *deb) 63 | { 64 | debugger=deb; 65 | align=debugger->getInstructionSize(0); 66 | } 67 | DebugInterface *getDebugger() 68 | { 69 | return debugger; 70 | } 71 | 72 | void onPaint(WPARAM wParam, LPARAM lParam); 73 | void onVScroll(WPARAM wParam, LPARAM lParam); 74 | void onKeyDown(WPARAM wParam, LPARAM lParam); 75 | void onMouseDown(WPARAM wParam, LPARAM lParam, int button); 76 | void onMouseUp(WPARAM wParam, LPARAM lParam, int button); 77 | void onMouseMove(WPARAM wParam, LPARAM lParam, int button); 78 | void redraw(); 79 | 80 | void setMode(MemViewMode m) 81 | { 82 | mode=m; 83 | switch(mode) { 84 | case MV_NORMAL: 85 | setAlign(16); 86 | break; 87 | case MV_SYMBOLS: 88 | setAlign(4); 89 | break; 90 | default: 91 | break; 92 | } 93 | redraw(); 94 | } 95 | void setAlign(int l) 96 | { 97 | align=l; 98 | } 99 | int yToAddress(int y); 100 | void gotoAddr(unsigned int addr) 101 | { 102 | curAddress=addr&(~(align-1)); 103 | redraw(); 104 | } 105 | unsigned int getSelection() 106 | { 107 | return curAddress; 108 | } 109 | }; -------------------------------------------------------------------------------- /nulldc/plugins/nullDC_GUI/DebugInterface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | class DebugInterface 5 | { 6 | public: 7 | virtual wchar *disasm(unsigned int address) {return L"NODEBUGGER";} 8 | virtual int getInstructionSize(int instruction) {return 1;} 9 | 10 | virtual bool isBreakpoint(unsigned int address) {return false;} 11 | virtual void setBreakpoint(unsigned int address){} 12 | virtual void clearBreakpoint(unsigned int address){} 13 | virtual void clearAllBreakpoints() {} 14 | virtual void toggleBreakpoint(unsigned int address){} 15 | virtual unsigned int readMemory(unsigned int address){return 0;} 16 | virtual unsigned int getPC() {return 0;} 17 | virtual void setPC(unsigned int address) {} 18 | virtual void step() {} 19 | virtual void runToBreakpoint() {} 20 | virtual int getColor(unsigned int address){return 0xFFFFFFFF;} 21 | virtual wchar *getDescription(unsigned int address) {return L"";} 22 | }; 23 | -------------------------------------------------------------------------------- /nulldc/plugins/nullDC_GUI/SH4DbgInterface.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | class SH4DebugInterface : public DebugInterface 5 | { 6 | public: 7 | SH4DebugInterface(){} 8 | virtual wchar *disasm(unsigned int address); 9 | virtual int getInstructionSize(int instruction) {return 2;} 10 | virtual bool isBreakpoint(unsigned int address); 11 | virtual void setBreakpoint(unsigned int address); 12 | virtual void clearBreakpoint(unsigned int address); 13 | virtual void clearAllBreakpoints(); 14 | virtual void toggleBreakpoint(unsigned int address); 15 | virtual unsigned int readMemory(unsigned int address); 16 | virtual unsigned int getPC(); 17 | virtual void setPC(unsigned int address); 18 | virtual void step() {} 19 | virtual void runToBreakpoint(); 20 | virtual int getColor(unsigned int address); 21 | virtual wchar *getDescription(unsigned int address); 22 | }; 23 | 24 | 25 | extern SH4DebugInterface di; -------------------------------------------------------------------------------- /nulldc/plugins/nullDC_GUI/Symbols.h: -------------------------------------------------------------------------------- 1 | // Symbols.h 2 | 3 | #define MAX_SYM_NAME 64 4 | 5 | typedef struct // *FIXME* redo ... 6 | { 7 | u32 size; 8 | u32 value; 9 | 10 | u8 bind; 11 | u8 type; 12 | 13 | u16 sec; 14 | 15 | char name[MAX_SYM_NAME]; 16 | 17 | } Symbol_Table, SymTable; 18 | 19 | extern SymTable *vSym; 20 | 21 | 22 | // LoadSymbolMap() -------------------------------------------------------------------------------- /nulldc/plugins/nullDC_GUI/emuWinUI.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skmp/nullDC-v1/1611c3cf0aa2755611455aa7a02b4f62babee7bd/nulldc/plugins/nullDC_GUI/emuWinUI.cpp -------------------------------------------------------------------------------- /nulldc/plugins/nullDC_GUI/emuWinUI.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "nullDC_GUI.h" 3 | 4 | u32 EXPORT_CALL AddMenuItem(u32 parent,s32 pos,const wchar* text,MenuItemSelectedFP* handler ,u32 checked); 5 | void EXPORT_CALL DeleteAllMenuItemChilds(u32 id); 6 | void EXPORT_CALL SetMenuItemStyle(u32 id,u32 style,u32 mask); 7 | void EXPORT_CALL GetMenuItem(u32 id,MenuItem* info,u32 mask); 8 | void EXPORT_CALL SetMenuItem(u32 id,MenuItem* info,u32 mask); 9 | void EXPORT_CALL DeleteMenuItem(u32 id); 10 | //These still exist , but are no longer given to plugins 11 | void EXPORT_CALL SetMenuItemHandler(u32 id,MenuItemSelectedFP* h); 12 | void EXPORT_CALL SetMenuItemBitmap(u32 id,void* hbmp); 13 | u32 EXPORT_CALL GetMenuItemStyle(u32 id); 14 | void* EXPORT_CALL GetMenuItemBitmap(u32 id); 15 | 16 | bool EXPORT_CALL SelectPluginsGui(); 17 | 18 | bool uiInit(); 19 | void uiTerm(); 20 | void uiMain(); 21 | 22 | extern u32 PowerVR_menu; 23 | extern u32 GDRom_menu; 24 | extern u32 Aica_menu; 25 | extern u32 Arm_menu; 26 | extern u32 Maple_menu; 27 | extern u32 Maple_menu_ports[4][6]; 28 | extern u32 ExtDev_menu; 29 | extern u32 Debug_menu; -------------------------------------------------------------------------------- /nulldc/plugins/nullDC_GUI/export.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | ndcGetInterface -------------------------------------------------------------------------------- /nulldc/plugins/nullDC_GUI/hwbrk.h: -------------------------------------------------------------------------------- 1 | // 2 | #ifndef _HWBRK_H 3 | #define _HWBRK_H 4 | 5 | enum HWBRK_TYPE 6 | { 7 | HWBRK_TYPE_CODE, 8 | HWBRK_TYPE_READWRITE, 9 | HWBRK_TYPE_WRITE, 10 | }; 11 | 12 | enum HWBRK_SIZE 13 | { 14 | HWBRK_SIZE_1, 15 | HWBRK_SIZE_2, 16 | HWBRK_SIZE_4, 17 | HWBRK_SIZE_8, 18 | }; 19 | 20 | HANDLE SetHardwareBreakpoint(HANDLE hThread,HWBRK_TYPE Type,HWBRK_SIZE Size,void* s); 21 | bool RemoveHardwareBreakpoint(HANDLE hBrk); 22 | 23 | 24 | #endif -------------------------------------------------------------------------------- /nulldc/plugins/nullDC_GUI/icon2.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skmp/nullDC-v1/1611c3cf0aa2755611455aa7a02b4f62babee7bd/nulldc/plugins/nullDC_GUI/icon2.ico -------------------------------------------------------------------------------- /nulldc/plugins/nullDC_GUI/icon3.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skmp/nullDC-v1/1611c3cf0aa2755611455aa7a02b4f62babee7bd/nulldc/plugins/nullDC_GUI/icon3.ico -------------------------------------------------------------------------------- /nulldc/plugins/nullDC_GUI/ndc_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skmp/nullDC-v1/1611c3cf0aa2755611455aa7a02b4f62babee7bd/nulldc/plugins/nullDC_GUI/ndc_icon.ico -------------------------------------------------------------------------------- /nulldc/plugins/nullDC_GUI/nulldc640_bluebg-opt96.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skmp/nullDC-v1/1611c3cf0aa2755611455aa7a02b4f62babee7bd/nulldc/plugins/nullDC_GUI/nulldc640_bluebg-opt96.jpeg -------------------------------------------------------------------------------- /nulldc/plugins/nullDC_GUI/screenshot.h: -------------------------------------------------------------------------------- 1 | #include 2 | bool Screenshot(LPCTSTR FileName, HWND hwnd); -------------------------------------------------------------------------------- /nulldc/plugins/nullExtDev/exports.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | dcGetInterface -------------------------------------------------------------------------------- /nulldc/plugins/nullExtDev/lan.cpp: -------------------------------------------------------------------------------- 1 | #include "lan.h" 2 | /* 3 | Huh, i used to have code in here o.O 4 | Ohh well, nothing to be missed 5 | */ 6 | 7 | u32 FASTCALL LanReadMem_A0_006(u32 addr,u32 size) 8 | { 9 | return 0; 10 | } 11 | void FASTCALL LanWriteMem_A0_006(u32 addr,u32 data,u32 size) 12 | { 13 | } -------------------------------------------------------------------------------- /nulldc/plugins/nullExtDev/lan.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "nullExtDev.h" 3 | 4 | u32 FASTCALL LanReadMem_A0_006(u32 addr,u32 size); 5 | void FASTCALL LanWriteMem_A0_006(u32 addr,u32 data,u32 size); -------------------------------------------------------------------------------- /nulldc/plugins/nullExtDev/modem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "nullExtDev.h" 3 | 4 | u32 FASTCALL ModemReadMem_A0_006(u32 addr,u32 size); 5 | void FASTCALL ModemWriteMem_A0_006(u32 addr,u32 data,u32 size); -------------------------------------------------------------------------------- /nulldc/plugins/nullExtDev/nullExtDev.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //bleh stupid windoze header 3 | #include "nullDC\plugins\plugin_header.h" 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | #define BUILD 0 12 | #define MINOR 0 13 | #define MAJOR 1 14 | 15 | #define DCclock (200*1000*1000) 16 | 17 | 18 | #define ReadMemArrRet(arr,addr,sz) \ 19 | {if (sz==1) \ 20 | return arr[addr]; \ 21 | else if (sz==2) \ 22 | return *(u16*)&arr[addr]; \ 23 | else if (sz==4) \ 24 | return *(u32*)&arr[addr];} 25 | 26 | #define WriteMemArrRet(arr,addr,data,sz) \ 27 | {if(sz==1) \ 28 | {arr[addr]=(u8)data;return;} \ 29 | else if (sz==2) \ 30 | {*(u16*)&arr[addr]=(u16)data;return;} \ 31 | else if (sz==4) \ 32 | {*(u32*)&arr[addr]=data;return;}} 33 | 34 | #define verify(x) if((x)==false){ printf("Verify Failed : " #x "\n in %s : %d \n",__FILE__,__LINE__);__debugbreak();} 35 | #define warn(x) if((x)==true){ printf("Warn Failed : " #x "\n in %s : %d \n",__FILE__,__LINE__);} 36 | 37 | #define naked __declspec( naked ) 38 | 39 | #define PAGE_SIZE 4096 40 | #define PAGE_MASL (PAGE_SIZE-1) 41 | 42 | void SetUpdateCallback(void (*callback) (),u32 ms); 43 | void ExpireUpdate(bool v=true); 44 | extern emu_info emu; 45 | extern ext_device_init_params params; 46 | struct __settings 47 | { 48 | u32 mode; 49 | u32 adapter; 50 | } ; 51 | 52 | extern __settings settings; 53 | 54 | void LoadSettings(); 55 | void SaveSettings(); -------------------------------------------------------------------------------- /nulldc/plugins/nullExtDev/nullExtDev.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {b9a763e3-28ca-4673-9276-33eb31d538c9} 10 | 11 | 12 | {d1e182b3-0f7f-4b34-a15b-4d29d7467bbc} 13 | 14 | 15 | {4de15486-a18c-4681-a54e-a2e8fbb0b2df} 16 | 17 | 18 | 19 | 20 | plugin 21 | 22 | 23 | 24 | 25 | plugin 26 | 27 | 28 | modem 29 | 30 | 31 | lan 32 | 33 | 34 | bba 35 | 36 | 37 | bba 38 | 39 | 40 | bba 41 | 42 | 43 | 44 | 45 | plugin 46 | 47 | 48 | modem 49 | 50 | 51 | lan 52 | 53 | 54 | bba 55 | 56 | 57 | bba 58 | 59 | 60 | 61 | 62 | bba 63 | 64 | 65 | -------------------------------------------------------------------------------- /nulldc/plugins/nullExtDev/pcap_io.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #pragma pack(push,1) 4 | 5 | typedef struct _ip_address 6 | { 7 | u_char bytes[4]; 8 | } ip_address; 9 | 10 | typedef struct _mac_address 11 | { 12 | u_char bytes[6]; 13 | } mac_address; 14 | 15 | typedef struct _ethernet_header 16 | { 17 | mac_address dst; 18 | mac_address src; 19 | u_short protocol; 20 | } ethernet_header; 21 | 22 | typedef struct _arp_packet 23 | { 24 | u_short hw_type; 25 | u_short protocol; 26 | u_char h_addr_len; 27 | u_char p_addr_len; 28 | u_short operation; 29 | mac_address h_src; 30 | ip_address p_src; 31 | mac_address h_dst; 32 | ip_address p_dst; 33 | } arp_packet; 34 | 35 | typedef struct _ip_header { 36 | u_char ip_vhl; /* version << 4 | header length >> 2 */ 37 | u_char ip_tos; /* type of service */ 38 | u_short ip_len; /* total length */ 39 | u_short ip_id; /* identification */ 40 | u_short ip_off; /* fragment offset field */ 41 | u_char ip_ttl; /* time to live */ 42 | u_char ip_p; /* protocol */ 43 | u_short ip_sum; /* checksum */ 44 | ip_address ip_src; /* source and dest address */ 45 | ip_address ip_dst; 46 | } ip_header; 47 | 48 | typedef struct _full_arp_packet 49 | { 50 | ethernet_header header; 51 | arp_packet arp; 52 | } full_arp_packet; 53 | 54 | #pragma pack(pop) 55 | 56 | #define ARP_REQUEST 0x0100 //values are big-endian 57 | 58 | extern mac_address virtual_mac; 59 | extern mac_address broadcast_mac; 60 | 61 | extern ip_address virtual_ip; 62 | 63 | #define mac_compare(a,b) (memcmp(&(a),&(b),6)) 64 | #define ip_compare(a,b) (memcmp(&(a),&(b),4)) 65 | 66 | int pcap_io_init(char *adapter); 67 | int pcap_io_send(void* packet, int plen); 68 | int pcap_io_recv(void* packet, int max_len); 69 | void pcap_io_close(); 70 | 71 | int pcap_io_get_dev_num(); 72 | char* pcap_io_get_dev_desc(int num); 73 | char* pcap_io_get_dev_name(int num); 74 | -------------------------------------------------------------------------------- /nulldc/plugins/vbaARM/aica.cpp: -------------------------------------------------------------------------------- 1 | #include "aica.h" 2 | #include "arm7.h" 3 | #include "mem.h" 4 | #include 5 | 6 | 7 | 8 | 9 | //Mainloop 10 | void FASTCALL UpdateARM(u32 Cycles) 11 | { 12 | arm_Run(Cycles/arm_sh4_bias); 13 | } 14 | -------------------------------------------------------------------------------- /nulldc/plugins/vbaARM/arm7.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "aica.h" 3 | 4 | void arm_Init(); 5 | void arm_Reset(); 6 | void arm_Run(u32 uNumCycles); 7 | void arm_SetEnabled(bool enabled); 8 | 9 | #define arm_sh4_bias (2) 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /nulldc/plugins/vbaARM/exports.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | dcGetInterface -------------------------------------------------------------------------------- /nulldc/plugins/vbaARM/mem.cpp: -------------------------------------------------------------------------------- 1 | #include "mem.h" 2 | #include "arm7.h" 3 | 4 | u8 *aica_ram; 5 | //Set to true when aica interrupt is pending 6 | bool aica_interr=false; 7 | u32 aica_reg_L=0; 8 | //Set to true when the out of the intc is 1 9 | bool e68k_out = false; 10 | u32 e68k_reg_L; 11 | u32 e68k_reg_M=0; //constant ? 12 | 13 | void update_e68k() 14 | { 15 | if (!e68k_out && aica_interr) 16 | { 17 | //Set the pending signal 18 | //Is L register holded here too ? 19 | e68k_out=1; 20 | e68k_reg_L=aica_reg_L; 21 | } 22 | } 23 | 24 | void FASTCALL ArmInterruptChange(u32 bits,u32 L) 25 | { 26 | aica_interr=bits!=0; 27 | if (aica_interr) 28 | aica_reg_L=L; 29 | update_e68k(); 30 | } 31 | 32 | void e68k_AcceptInterrupt() 33 | { 34 | e68k_out=false; 35 | update_e68k(); 36 | } 37 | 38 | //Reg reads from arm side .. 39 | template 40 | inline T fastcall arm_ReadReg(u32 addr) 41 | { 42 | addr&=0x7FFF; 43 | if (addr==REG_L) 44 | return e68k_reg_L; 45 | else if(addr==REG_M) 46 | return e68k_reg_M; //shoudn't really happen 47 | else 48 | return arm_params.ReadMem_aica_reg(addr,sz); 49 | } 50 | template 51 | inline void fastcall arm_WriteReg(u32 addr,T data) 52 | { 53 | addr&=0x7FFF; 54 | if (addr==REG_L) 55 | return; //shoudn't really happen (read only) 56 | else if(addr==REG_M) 57 | { 58 | //accept interrupts 59 | if (data&1) 60 | e68k_AcceptInterrupt(); 61 | } 62 | else 63 | return arm_params.WriteMem_aica_reg(addr,data,sz); 64 | } 65 | //Map using _vmem .. yay 66 | void init_mem() 67 | { 68 | aica_ram=arm_params.aica_ram; 69 | } 70 | //kill mem map & free used mem ;) 71 | void term_mem() 72 | { 73 | 74 | } 75 | 76 | //00000000~007FFFFF @DRAM_AREA* 77 | //00800000~008027FF @CHANNEL_DATA 78 | //00802800~00802FFF @COMMON_DATA 79 | //00803000~00807FFF @DSP_DATA 80 | 81 | //Force alignment for read/writes to mem 82 | #define ACCESS_MASK (ARAM_MASK-(sz-1)) 83 | 84 | template 85 | T fastcall ReadMemArm(u32 addr) 86 | { 87 | addr&=0x00FFFFFF; 88 | if (addr<0x800000) 89 | { 90 | T rv=*(T*)&aica_ram[addr&ACCESS_MASK]; 91 | 92 | if (sz==4) 93 | { 94 | //32 bit misalligned reads: rotated 95 | u32 rot=(addr&3)<<3; 96 | return (rv>>rot) | (rv<<(32-rot)); 97 | } 98 | else 99 | return rv; 100 | } 101 | else 102 | { 103 | return arm_ReadReg(addr); 104 | } 105 | } 106 | 107 | template 108 | void fastcall WriteMemArm(u32 addr,T data) 109 | { 110 | addr&=0x00FFFFFF; 111 | if (addr<0x800000) 112 | { 113 | *(T*)&aica_ram[addr&ACCESS_MASK]=data; 114 | } 115 | else 116 | { 117 | arm_WriteReg(addr,data); 118 | } 119 | } 120 | 121 | template u8 ReadMemArm<1,u8>(u32 adr); 122 | template u16 ReadMemArm<2,u16>(u32 adr); 123 | template u32 ReadMemArm<4,u32>(u32 adr); 124 | 125 | template void WriteMemArm<1>(u32 adr,u8 data); 126 | template void WriteMemArm<2>(u32 adr,u16 data); 127 | template void WriteMemArm<4>(u32 adr,u32 data); 128 | 129 | -------------------------------------------------------------------------------- /nulldc/plugins/vbaARM/mem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "aica.h" 3 | 4 | template 5 | T fastcall ReadMemArm(u32 addr); 6 | template 7 | void fastcall WriteMemArm(u32 addr,T data); 8 | 9 | #define arm_ReadMem8 ReadMemArm<1,u8> 10 | #define arm_ReadMem16 ReadMemArm<2,u16> 11 | #define arm_ReadMem32 ReadMemArm<4,u32> 12 | 13 | #define arm_WriteMem8 WriteMemArm<1,u8> 14 | #define arm_WriteMem16 WriteMemArm<2,u16> 15 | #define arm_WriteMem32 WriteMemArm<4,u32> 16 | 17 | u32 FASTCALL sh4_ReadMem_reg(u32 addr,u32 size); 18 | void FASTCALL sh4_WriteMem_reg(u32 addr,u32 data,u32 size); 19 | 20 | void init_mem(); 21 | void term_mem(); 22 | 23 | extern u8 *aica_ram; 24 | #define aica_reg_16 ((u16*)aica_reg) 25 | 26 | #define AICA_RAM_SIZE (ARAM_SIZE) 27 | #define AICA_RAM_MASK (ARAM_MASK) 28 | 29 | #define AICA_MEMMAP_RAM_SIZE (8*1024*1024) //this is the max for the map, the actual ram size is AICA_RAM_SIZE 30 | #define AICA_MEMMAP_RAM_MASK (AICA_MEMMAP_RAM_SIZE-1) -------------------------------------------------------------------------------- /nulldc/plugins/vbaARM/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by sdlAICA.rc 4 | // 5 | #define IDD_SETTINGS 101 6 | #define IDD_DIALOG1 102 7 | #define IDD_DEBUGGER 102 8 | #define IDC_RADIO1 1002 9 | #define IDC_RADIO2 1003 10 | #define IDC_RADIO3 1004 11 | #define IDC_RADIO4 1005 12 | #define IDC_RADIO5 1006 13 | #define IDC_HWMIX 1007 14 | #define IDC_GFOCUS 1009 15 | #define IDC_FSYNC 1010 16 | #define IDC_RADIO6 1016 17 | #define IDC_RADIO7 1018 18 | 19 | // Next default values for new objects 20 | // 21 | #ifdef APSTUDIO_INVOKED 22 | #ifndef APSTUDIO_READONLY_SYMBOLS 23 | #define _APS_NEXT_RESOURCE_VALUE 103 24 | #define _APS_NEXT_COMMAND_VALUE 40001 25 | #define _APS_NEXT_CONTROL_VALUE 1011 26 | #define _APS_NEXT_SYMED_VALUE 101 27 | #endif 28 | #endif 29 | -------------------------------------------------------------------------------- /nulldc/plugins/vbaARM/vbaARM.cpp: -------------------------------------------------------------------------------- 1 | // nullAICA.cpp : Defines the entry point for the DLL application. 2 | // 3 | 4 | #include "vbaARM.h" 5 | #include "aica.h" 6 | #include "arm7.h" 7 | #include "mem.h" 8 | #include 9 | 10 | arm_init_params arm_params; 11 | emu_info eminf; 12 | HINSTANCE hinst; 13 | BOOL APIENTRY DllMain( HMODULE hModule, 14 | DWORD ul_reason_for_call, 15 | LPVOID lpReserved 16 | ) 17 | { 18 | hinst=(HINSTANCE)hModule; 19 | return TRUE; 20 | } 21 | void EXPORT_CALL handle_About(u32 id,void* w,void* p) 22 | { 23 | MessageBoxA((HWND)w,"Made by the VBA Team\r\nPorted by drk||Raziel","About the VBA ARM Core...",MB_ICONINFORMATION); 24 | } 25 | s32 FASTCALL OnLoad(emu_info* em) 26 | { 27 | memcpy(&eminf,em,sizeof(eminf)); 28 | 29 | LoadSettings(); 30 | eminf.AddMenuItem(em->RootMenu,-1,L"About",handle_About,0); 31 | return rv_ok; 32 | } 33 | 34 | void FASTCALL OnUnload() 35 | { 36 | } 37 | 38 | //called when plugin is used by emu (you should do first time init here) 39 | s32 FASTCALL Init(arm_init_params* initp) 40 | { 41 | memcpy(&arm_params,initp,sizeof(arm_params)); 42 | 43 | init_mem(); 44 | arm_Init(); 45 | 46 | return rv_ok; 47 | } 48 | 49 | //called when plugin is unloaded by emu , olny if dcInit is called (eg , not called to enumerate plugins) 50 | void FASTCALL Term() 51 | { 52 | term_mem(); 53 | //arm7_Term ? 54 | } 55 | 56 | //It's suposed to reset anything 57 | void FASTCALL Reset(bool Manual) 58 | { 59 | arm_Reset(); 60 | } 61 | 62 | void FASTCALL SetResetState(u32 state) 63 | { 64 | arm_SetEnabled(state==0); 65 | } 66 | //Give to the emu pointers for the PowerVR interface 67 | EXPORT void EXPORT_CALL dcGetInterface(plugin_interface* info) 68 | { 69 | info->InterfaceVersion=PLUGIN_I_F_VERSION; 70 | 71 | #define c info->common 72 | #define a info->arm 73 | 74 | wcscpy(c.Name,L"VBA ARM Sound Cpu Core [" _T(__DATE__) L"]"); 75 | 76 | c.InterfaceVersion=ARM_PLUGIN_I_F_VERSION; 77 | c.Type=Plugin_ARM; 78 | 79 | c.Load=OnLoad; 80 | c.Unload=OnUnload; 81 | 82 | a.Init=Init; 83 | a.Reset=Reset; 84 | a.Term=Term; 85 | 86 | a.Update=UpdateARM; 87 | a.ArmInterruptChange=ArmInterruptChange; 88 | a.ExeptionHanlder=0; 89 | a.SetResetState=SetResetState; 90 | } 91 | 92 | int cfgGetInt(char* key,int def) 93 | { 94 | wchar t[512]; 95 | mbstowcs(t,key,512); 96 | return eminf.ConfigLoadInt(L"nullAica",t,def); 97 | } 98 | void cfgSetInt(char* key,int def) 99 | { 100 | wchar t[512]; 101 | mbstowcs(t,key,512); 102 | eminf.ConfigSaveInt(L"nullAica",t,def); 103 | } 104 | 105 | void LoadSettings() 106 | { 107 | //load default settings before init 108 | //settings.BufferSize=cfgGetInt("BufferSize",1024); 109 | } 110 | 111 | void SaveSettings() 112 | { 113 | 114 | } -------------------------------------------------------------------------------- /nulldc/plugins/vbaARM/vbaARM.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //bleh stupid windoze header 3 | #include "nullDC\plugins\plugin_header.h" 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | #define BUILD 0 11 | #define MINOR 1 12 | #define MAJOR 0 13 | 14 | #define DCclock (200*1000*1000) 15 | 16 | //called when plugin is used by emu (you should do first time init here) 17 | void dcInit(void* param,PluginType type); 18 | 19 | //called when plugin is unloaded by emu , olny if dcInit is called (eg , not called to enumerate plugins) 20 | void dcTerm(PluginType type); 21 | 22 | //It's suposed to reset anything 23 | void dcReset(bool Manual,PluginType type); 24 | 25 | //called when entering sh4 thread , from the new thread context (for any thread speciacific init) 26 | void dcThreadInit(PluginType type); 27 | 28 | //called when exiting from sh4 thread , from the new thread context (for any thread speciacific de init) :P 29 | void dcThreadTerm(PluginType type); 30 | 31 | #define ReadMemArrRet(arr,addr,sz) \ 32 | {if (sz==1) \ 33 | return arr[addr]; \ 34 | else if (sz==2) \ 35 | return *(u16*)&arr[addr]; \ 36 | else if (sz==4) \ 37 | return *(u32*)&arr[addr];} 38 | 39 | #define WriteMemArrRet(arr,addr,data,sz) \ 40 | {if(sz==1) \ 41 | {arr[addr]=(u8)data;return;} \ 42 | else if (sz==2) \ 43 | {*(u16*)&arr[addr]=(u16)data;return;} \ 44 | else if (sz==4) \ 45 | {*(u32*)&arr[addr]=data;return;}} 46 | #define WriteMemArr(arr,addr,data,sz) \ 47 | {if(sz==1) \ 48 | {arr[addr]=(u8)data;} \ 49 | else if (sz==2) \ 50 | {*(u16*)&arr[addr]=(u16)data;} \ 51 | else if (sz==4) \ 52 | {*(u32*)&arr[addr]=data;}} 53 | 54 | extern arm_init_params arm_params; 55 | extern emu_info eminf; 56 | #define naked __declspec( naked ) 57 | 58 | void LoadSettings(); 59 | void SaveSettings(); 60 | 61 | #define dbgbreak { __debugbreak();/* printf("Press ANY key to continue\n");getchar();*/} 62 | 63 | #define fastcall __fastcall 64 | #define verify(x) if((x)==false){ printf("Verify Failed : " #x "\n in %s -> %s : %d \n",__FUNCTION__,__FILE__,__LINE__); dbgbreak;} 65 | #define verifyc(x) if(FAILED(x)){ printf("Verify Failed : " #x "\n in %s -> %s : %d \n",__FUNCTION__,__FILE__,__LINE__); dbgbreak;} 66 | #define die(reason) { printf("Fatal error : %s\n in %s -> %s : %d \n",reason,__FUNCTION__,__FILE__,__LINE__); dbgbreak;} 67 | #define fverify verify 68 | 69 | int cfgGetInt(char* key,int def); 70 | 71 | extern HINSTANCE hinst; -------------------------------------------------------------------------------- /nulldc/plugins/vbaARM/vbaARM.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {0968b9a6-1e62-46d9-985a-003c83248df7} 10 | 11 | 12 | {321d10c9-5653-4392-9fd1-6257bc8e1b1b} 13 | 14 | 15 | 16 | 17 | plugin 18 | 19 | 20 | 21 | 22 | plugin 23 | 24 | 25 | arm7 26 | 27 | 28 | mem 29 | 30 | 31 | plugin 32 | 33 | 34 | 35 | 36 | plugin 37 | 38 | 39 | arm7 40 | 41 | 42 | arm7 43 | 44 | 45 | mem 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /nulldc/running.txt: -------------------------------------------------------------------------------- 1 | Running the emulator should require those: 2 | 3 | The same Visual C++ Runtime and DirectX 9.0c versions that were used to compile the emulator and/or the plugins. 4 | 5 | The same rule applies to SDL, WinPcap and the Logitech LCD thing. If you miss the compiled libraries of those and the plugins/emulator were compiled with those development libraries, their features will either not work, or the emulator will not work at all. 6 | 7 | ImgReader uses the .CDI File Mounter (pfctoc.dll) from Padus to mount .cdi images. Those images will not work without it. You should get it and place it in the plugins directory of the emulator (where ImgReader_Win32.dll is placed). 8 | 9 | EOF --------------------------------------------------------------------------------