├── .gitignore ├── LICENSE ├── README.md ├── gp2 ├── emu │ ├── changelog │ ├── cpu │ │ ├── cpuintrf.h │ │ ├── debug.txt │ │ ├── osd_cpu.h │ │ ├── z80.c │ │ ├── z80.h │ │ └── z80daa.h │ ├── dos │ │ ├── SEALINTF.C │ │ ├── SEALINTF.H │ │ ├── config.c │ │ ├── config.h │ │ ├── dos.c │ │ ├── dos.h │ │ ├── error.c │ │ ├── error.h │ │ └── osd.h │ ├── fileio.c │ ├── fileio.h │ ├── gen_input.c │ ├── gen_input.h │ ├── gen_io.c │ ├── gen_io.h │ ├── genesis.c │ ├── genesis.h │ ├── hcnt.h │ ├── hvc.h │ ├── io.c │ ├── io.h │ ├── license │ ├── loadrom.c │ ├── loadrom.h │ ├── m68k.rar │ ├── m68k │ │ ├── MAKE.BAT │ │ ├── clean.bat │ │ ├── debug.txt │ │ ├── m68k.h │ │ ├── m68k.rar │ │ ├── m68k_in.c │ │ ├── m68kconf.h │ │ ├── m68kcpu.c │ │ ├── m68kcpu.h │ │ ├── m68kdasm.c │ │ ├── m68kmake.c │ │ ├── m68kopac.c │ │ ├── m68kopdm.c │ │ ├── m68kopnz.c │ │ ├── m68kops.c │ │ ├── m68kops.h │ │ └── readme.txt │ ├── macros.h │ ├── make.bat │ ├── makefile.dj2 │ ├── makefile.mgw │ ├── mem68k.c │ ├── mem68k.h │ ├── membnk.c │ ├── membnk.h │ ├── memvdp.c │ ├── memvdp.h │ ├── memz80.c │ ├── memz80.h │ ├── porting.txt │ ├── readme.txt │ ├── render.c │ ├── render.h │ ├── shared.h │ ├── sound │ │ ├── fm.c │ │ ├── fm.h │ │ ├── sn76496.c │ │ ├── sn76496.h │ │ ├── sound.c │ │ └── sound.h │ ├── system.c │ ├── system.h │ ├── todo.txt │ ├── types.h │ ├── unzip.c │ ├── unzip.h │ ├── vcnt.h │ ├── vdp.c │ ├── vdp.h │ ├── win │ │ ├── error.c │ │ ├── error.h │ │ ├── main.c │ │ ├── main.h │ │ └── osd.h │ └── zip │ │ ├── UNZIP.C │ │ ├── UNZIP.H │ │ ├── zconf.h │ │ ├── zip.zip │ │ ├── zlib.h │ │ └── zlib.lib ├── gp2.dsp ├── gp2.dsw ├── gp2.vcproj ├── gp2.vcxproj ├── gp2.vcxproj.filters └── main.c └── mdstudio ├── CEPI_IHM.exe.manifest ├── DXKeyboard.cpp ├── include ├── DXKeyboard.h ├── mdApp.h ├── mdBreakPoint.h ├── mdCRAMPanel.h ├── mdDefaultPlugin.h ├── mdDibBitmap.h ├── mdDisAsmPanel.h ├── mdDisasm.h ├── mdEmu.h ├── mdFrmDumpBin.h ├── mdFrmGoto.h ├── mdFrmMain.h ├── mdFrmSpyAttr.h ├── mdFrmVDPAddrCalc.h ├── mdFrmVdpCalc.h ├── mdGotoPanel.h ├── mdList.h ├── mdListLine.h ├── mdLogPanel.h ├── mdOutputDataPlugin.h ├── mdPlugin.h ├── mdPluginList.h ├── mdProgressStatusBar.h ├── mdProject.h ├── mdProxy.h ├── mdRegPanel.h ├── mdRegistersDisplay.h ├── mdSDK.h ├── mdScreen.h ├── mdSection.h ├── mdShared.h ├── mdSpiesPanel.h ├── mdSpy.h ├── mdSymbol.h ├── mdSymbolPair.h ├── mdSymbolsPanel.h ├── mdTextCtrl.h ├── mdTileViewerPanel.h ├── mdVDPStatusPanel.h ├── mdVdpAddrCalc.h ├── mdVdpViewer.h ├── mdVideoAdapter.h ├── mdVideoPanel.h ├── mdVideoSurface.h └── mdvdpRegInfo.h ├── mdstudio.dsp ├── mdstudio.dsw ├── mdstudio.sln ├── mdstudio.vcproj ├── mdstudio.vcxproj ├── mdstudio.vcxproj.filters ├── plugins ├── genesisplus.dll ├── out_bmp │ ├── out_bmp.cpp │ └── out_bmp.dsp ├── out_pcx.dll └── out_pcx │ ├── out_pcx.cpp │ ├── out_pcx.dsp │ └── out_pcx.vcproj ├── setup └── Setup │ └── Setup.vdproj ├── src ├── mdApp.cpp ├── mdBreakPoint.cpp ├── mdCRAMPanel.cpp ├── mdDefaultPlugin.cpp ├── mdDibBitmap.cpp ├── mdDisAsmPanel.cpp ├── mdDisasm.cpp ├── mdEmu.cpp ├── mdFrmDumpBin.cpp ├── mdFrmGoto.cpp ├── mdFrmMain.cpp ├── mdFrmSpyAttr.cpp ├── mdFrmVDPAddrCalc.cpp ├── mdFrmVdpCalc.cpp ├── mdGotoPanel.cpp ├── mdListLine.cpp ├── mdLogPanel.cpp ├── mdOutputDataPlugin.cpp ├── mdPlugin.cpp ├── mdPluginList.cpp ├── mdProgressStatusBar.cpp ├── mdProject.cpp ├── mdProxy.cpp ├── mdRegPanel.cpp ├── mdRegistersDisplay.cpp ├── mdScreen.cpp ├── mdSection.cpp ├── mdSpiesPanel.cpp ├── mdSpy.cpp ├── mdSymbol.cpp ├── mdSymbolPair.cpp ├── mdSymbolsPanel.cpp ├── mdTextCtrl.cpp ├── mdTileViewerPanel.cpp ├── mdVDPStatusPanel.cpp ├── mdVdpAddrCalc.cpp ├── mdVdpViewer.cpp ├── mdVideoAdapter.cpp ├── mdVideoPanel.cpp └── mdVideoSurface.cpp └── vc_mswd └── mdstudio.idb /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | *.VC.VC.opendb 85 | 86 | # Visual Studio profiler 87 | *.psess 88 | *.vsp 89 | *.vspx 90 | *.sap 91 | 92 | # TFS 2012 Local Workspace 93 | $tf/ 94 | 95 | # Guidance Automation Toolkit 96 | *.gpState 97 | 98 | # ReSharper is a .NET coding add-in 99 | _ReSharper*/ 100 | *.[Rr]e[Ss]harper 101 | *.DotSettings.user 102 | 103 | # JustCode is a .NET coding add-in 104 | .JustCode 105 | 106 | # TeamCity is a build add-in 107 | _TeamCity* 108 | 109 | # DotCover is a Code Coverage Tool 110 | *.dotCover 111 | 112 | # NCrunch 113 | _NCrunch_* 114 | .*crunch*.local.xml 115 | nCrunchTemp_* 116 | 117 | # MightyMoose 118 | *.mm.* 119 | AutoTest.Net/ 120 | 121 | # Web workbench (sass) 122 | .sass-cache/ 123 | 124 | # Installshield output folder 125 | [Ee]xpress/ 126 | 127 | # DocProject is a documentation generator add-in 128 | DocProject/buildhelp/ 129 | DocProject/Help/*.HxT 130 | DocProject/Help/*.HxC 131 | DocProject/Help/*.hhc 132 | DocProject/Help/*.hhk 133 | DocProject/Help/*.hhp 134 | DocProject/Help/Html2 135 | DocProject/Help/html 136 | 137 | # Click-Once directory 138 | publish/ 139 | 140 | # Publish Web Output 141 | *.[Pp]ublish.xml 142 | *.azurePubxml 143 | # TODO: Comment the next line if you want to checkin your web deploy settings 144 | # but database connection strings (with potential passwords) will be unencrypted 145 | *.pubxml 146 | *.publishproj 147 | 148 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 149 | # checkin your Azure Web App publish settings, but sensitive information contained 150 | # in these scripts will be unencrypted 151 | PublishScripts/ 152 | 153 | # NuGet Packages 154 | *.nupkg 155 | # The packages folder can be ignored because of Package Restore 156 | **/packages/* 157 | # except build/, which is used as an MSBuild target. 158 | !**/packages/build/ 159 | # Uncomment if necessary however generally it will be regenerated when needed 160 | #!**/packages/repositories.config 161 | # NuGet v3's project.json files produces more ignoreable files 162 | *.nuget.props 163 | *.nuget.targets 164 | 165 | # Microsoft Azure Build Output 166 | csx/ 167 | *.build.csdef 168 | 169 | # Microsoft Azure Emulator 170 | ecf/ 171 | rcf/ 172 | 173 | # Windows Store app package directories and files 174 | AppPackages/ 175 | BundleArtifacts/ 176 | Package.StoreAssociation.xml 177 | _pkginfo.txt 178 | 179 | # Visual Studio cache files 180 | # files ending in .cache can be ignored 181 | *.[Cc]ache 182 | # but keep track of directories ending in .cache 183 | !*.[Cc]ache/ 184 | 185 | # Others 186 | ClientBin/ 187 | ~$* 188 | *~ 189 | *.dbmdl 190 | *.dbproj.schemaview 191 | *.pfx 192 | *.publishsettings 193 | node_modules/ 194 | orleans.codegen.cs 195 | 196 | # Since there are multiple workflows, uncomment next line to ignore bower_components 197 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 198 | #bower_components/ 199 | 200 | # RIA/Silverlight projects 201 | Generated_Code/ 202 | 203 | # Backup & report files from converting an old project file 204 | # to a newer Visual Studio version. Backup files are not needed, 205 | # because we have git ;-) 206 | _UpgradeReport_Files/ 207 | Backup*/ 208 | UpgradeLog*.XML 209 | UpgradeLog*.htm 210 | 211 | # SQL Server files 212 | *.mdf 213 | *.ldf 214 | 215 | # Business Intelligence projects 216 | *.rdl.data 217 | *.bim.layout 218 | *.bim_*.settings 219 | 220 | # Microsoft Fakes 221 | FakesAssemblies/ 222 | 223 | # GhostDoc plugin setting file 224 | *.GhostDoc.xml 225 | 226 | # Node.js Tools for Visual Studio 227 | .ntvs_analysis.dat 228 | 229 | # Visual Studio 6 build log 230 | *.plg 231 | 232 | # Visual Studio 6 workspace options file 233 | *.opt 234 | 235 | # Visual Studio LightSwitch build output 236 | **/*.HTMLClient/GeneratedArtifacts 237 | **/*.DesktopClient/GeneratedArtifacts 238 | **/*.DesktopClient/ModelManifest.xml 239 | **/*.Server/GeneratedArtifacts 240 | **/*.Server/ModelManifest.xml 241 | _Pvt_Extensions 242 | 243 | # Paket dependency manager 244 | .paket/paket.exe 245 | paket-files/ 246 | 247 | # FAKE - F# Make 248 | .fake/ 249 | 250 | # JetBrains Rider 251 | .idea/ 252 | *.sln.iml 253 | *.old 254 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Megadrive-Studio 2 | 3 | Megadrive Studio , is a debugger for the Megadrive/Genesis System 4 | it focus on SNASM68K, as it can load symbols from the .map outputed by that compiler. But it can load any megadrive game 5 | 6 | The project is oooooooold , it was programmed in 2005, and is based on Genesis Plus from Charles McDonald. 7 | 8 | ![alt tag](https://cloud.githubusercontent.com/assets/25900414/24675016/e53a0808-197d-11e7-901f-8b3adef8d806.png) 9 | 10 | you can : 11 | - See disassembly code 12 | - Step into code 13 | - Step a frame 14 | - Dump 68k, z80, vram, vsram, ram 15 | - vdp registers calculator 16 | - Support Gens KMOD debugging features 17 | - write to vdp reg #29 to force a code break 18 | - write to vdp reg #30 to log a char 19 | 20 | # How to compile 21 | This is an really old program 2005, that means centuries in IT world. 22 | Hopefuylly, i saved the libraries and I successfully recompile it using Visual Studio 2010. All the libraries are available 23 | 24 | - DirectX SDK : http://pascalorama.com/mdstudiopre/dxsdk_jun2007.exe 25 | - wxWindows : http://pascalorama.com/mdstudiopre/wxMSW-2.6.3-1.zip 26 | - wxDockit : http://pascalorama.com/mdstudiopre/wxDockIt_2.1.zip 27 | 28 | define a system variable (WXWIN) pointing to the wx folder 29 | for example on my system : c:\sdk\wx 30 | 31 | compile in this order : wxwindow , wxdockit , mdstudio 32 | 33 | for wxwindows and wxdockit use the solution in theirs respective folder : build\msw 34 | -------------------------------------------------------------------------------- /gp2/emu/changelog: -------------------------------------------------------------------------------- 1 | 2 | [04/20/03] 3 | - Modified 68000 emulator to prevent 'tas.b $mem' from writing data back 4 | after a read (fixes Gargoyles). 5 | - Fixed bug in 68000 emulator to swap order of words written for address 6 | register indirect pre-decremented writes (fixes Jim Power graphics). 7 | - Added support for 240-line displays (for Super Skidmarks). 8 | - Rewrote part of the interrupt handling (fixes some raster effects). 9 | - Removed sprite collision detection code (never really worked). 10 | - Optimized sprite rendering inner loop. 11 | 12 | [04/13/03] 13 | - Finished up memory map for VDP DMA V-bus reads. 14 | - Fixed handling of 68000 writes to I/O chip at even addresses. 15 | - Fixed bit 7 handling of control register in I/O chip. 16 | - Finished up Z80 memory map. 17 | - Added code to handle Genesis hardware lock-ups. 18 | - Removed some faulty code from the 68000 memory map handlers. 19 | 20 | [03/22/03] 21 | - Completed implementation of Z80 banked memory handlers. 22 | 23 | -------------------------------------------------------------------------------- /gp2/emu/cpu/cpuintrf.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef CPUINTRF_H 3 | #define CPUINTRF_H 4 | 5 | #include "osd_cpu.h" 6 | 7 | #define CPU_16BIT_PORT 0x4000 8 | #define CPU_FLAGS_MASK 0xff00 9 | #define CLEAR_LINE 0 10 | #define ASSERT_LINE 1 11 | #define REG_PREVIOUSPC -1 12 | #define REG_SP_CONTENTS -2 13 | 14 | /* daisy-chain link */ 15 | typedef struct { 16 | void (*reset)(int); /* reset callback */ 17 | int (*interrupt_entry)(int); /* entry callback */ 18 | void (*interrupt_reti)(int); /* reti callback */ 19 | int irq_param; /* callback paramater */ 20 | } Z80_DaisyChain; 21 | 22 | #define Z80_MAXDAISY 4 /* maximum of daisy chan device */ 23 | 24 | #define Z80_INT_REQ 0x01 /* interrupt request mask */ 25 | #define Z80_INT_IEO 0x02 /* interrupt disable mask(IEO) */ 26 | 27 | #define Z80_VECTOR(device,state) (((device)<<8)|(state)) 28 | 29 | 30 | #endif /* CPUINTRF_H */ 31 | -------------------------------------------------------------------------------- /gp2/emu/cpu/osd_cpu.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * * 3 | * Define size independent data types and operations. * 4 | * * 5 | * The following types must be supported by all platforms: * 6 | * * 7 | * UINT8 - Unsigned 8-bit Integer INT8 - Signed 8-bit integer * 8 | * UINT16 - Unsigned 16-bit Integer INT16 - Signed 16-bit integer * 9 | * UINT32 - Unsigned 32-bit Integer INT32 - Signed 32-bit integer * 10 | * UINT64 - Unsigned 64-bit Integer INT64 - Signed 64-bit integer * 11 | * * 12 | * * 13 | * The macro names for the artithmatic operations are composed as follows: * 14 | * * 15 | * XXX_R_A_B, where XXX - 3 letter operation code (ADD, SUB, etc.) * 16 | * R - The type of the result * 17 | * A - The type of operand 1 * 18 | * B - The type of operand 2 (if binary operation) * 19 | * * 20 | * Each type is one of: U8,8,U16,16,U32,32,U64,64 * 21 | * * 22 | *******************************************************************************/ 23 | 24 | 25 | #ifndef OSD_CPU_H 26 | #define OSD_CPU_H 27 | 28 | #ifndef DOS 29 | #include "basetsd.h" 30 | #endif 31 | 32 | typedef unsigned char UINT8; 33 | typedef unsigned short UINT16; 34 | #ifdef DOS 35 | typedef unsigned int UINT32; 36 | __extension__ typedef unsigned long long UINT64; 37 | #endif 38 | typedef signed char INT8; 39 | typedef signed short INT16; 40 | #ifdef DOS 41 | typedef signed int INT32; 42 | __extension__ typedef signed long long INT64; 43 | #endif 44 | 45 | /* Combine two 32-bit integers into a 64-bit integer */ 46 | #define COMBINE_64_32_32(A,B) ((((UINT64)(A))<<32) | (UINT32)(B)) 47 | #define COMBINE_U64_U32_U32(A,B) COMBINE_64_32_32(A,B) 48 | 49 | /* Return upper 32 bits of a 64-bit integer */ 50 | #define HI32_32_64(A) (((UINT64)(A)) >> 32) 51 | #define HI32_U32_U64(A) HI32_32_64(A) 52 | 53 | /* Return lower 32 bits of a 64-bit integer */ 54 | #define LO32_32_64(A) ((A) & 0xffffffff) 55 | #define LO32_U32_U64(A) LO32_32_64(A) 56 | 57 | #define DIV_64_64_32(A,B) ((A)/(B)) 58 | #define DIV_U64_U64_U32(A,B) ((A)/(UINT32)(B)) 59 | 60 | #define MOD_32_64_32(A,B) ((A)%(B)) 61 | #define MOD_U32_U64_U32(A,B) ((A)%(UINT32)(B)) 62 | 63 | #define MUL_64_32_32(A,B) ((A)*(INT64)(B)) 64 | #define MUL_U64_U32_U32(A,B) ((A)*(UINT64)(UINT32)(B)) 65 | 66 | 67 | /****************************************************************************** 68 | * Union of UINT8, UINT16 and UINT32 in native endianess of the target 69 | * This is used to access bytes and words in a machine independent manner. 70 | * The upper bytes h2 and h3 normally contain zero (16 bit CPU cores) 71 | * thus PAIR.d can be used to pass arguments to the memory system 72 | * which expects 'int' really. 73 | ******************************************************************************/ 74 | typedef union { 75 | #ifdef LSB_FIRST 76 | struct { UINT8 l,h,h2,h3; } b; 77 | struct { UINT16 l,h; } w; 78 | #else 79 | struct { UINT8 h3,h2,h,l; } b; 80 | struct { UINT16 h,l; } w; 81 | #endif 82 | UINT32 d; 83 | } PAIR; 84 | 85 | #endif /* defined OSD_CPU_H */ 86 | -------------------------------------------------------------------------------- /gp2/emu/cpu/z80.h: -------------------------------------------------------------------------------- 1 | #ifndef Z80_H 2 | #define Z80_H 3 | 4 | #include "cpuintrf.h" 5 | #include "osd_cpu.h" 6 | 7 | enum { 8 | Z80_PC=1, Z80_SP, Z80_AF, Z80_BC, Z80_DE, Z80_HL, 9 | Z80_IX, Z80_IY, Z80_AF2, Z80_BC2, Z80_DE2, Z80_HL2, 10 | Z80_R, Z80_I, Z80_IM, Z80_IFF1, Z80_IFF2, Z80_HALT, 11 | Z80_NMI_STATE, Z80_IRQ_STATE, Z80_DC0, Z80_DC1, Z80_DC2, Z80_DC3 12 | }; 13 | 14 | enum { 15 | Z80_TABLE_op, 16 | Z80_TABLE_cb, 17 | Z80_TABLE_ed, 18 | Z80_TABLE_xy, 19 | Z80_TABLE_xycb, 20 | Z80_TABLE_ex /* cycles counts for taken jr/jp/call and interrupt latency (rst opcodes) */ 21 | }; 22 | 23 | extern int z80_ICount; /* T-state count */ 24 | 25 | #define Z80_IGNORE_INT -1 /* Ignore interrupt */ 26 | #define Z80_NMI_INT -2 /* Execute NMI */ 27 | #define Z80_IRQ_INT -1000 /* Execute IRQ */ 28 | 29 | extern void z80_reset (void *param); 30 | extern void z80_exit (void); 31 | extern void z80_end_timeslice(void); 32 | extern int z80_execute(int cycles); 33 | extern void z80_burn(int cycles); 34 | extern unsigned z80_get_context (void *dst); 35 | extern void z80_set_context (void *src); 36 | extern void *z80_get_cycle_table (int which); 37 | extern void z80_set_cycle_table (int which, void *new_tbl); 38 | extern unsigned z80_get_pc (void); 39 | extern void z80_set_pc (unsigned val); 40 | extern unsigned z80_get_sp (void); 41 | extern void z80_set_sp (unsigned val); 42 | extern unsigned z80_get_reg (int regnum); 43 | extern void z80_set_reg (int regnum, unsigned val); 44 | extern void z80_set_nmi_line(int state); 45 | extern void z80_set_irq_line(int irqline, int state); 46 | extern void z80_set_irq_callback(int (*irq_callback)(int)); 47 | extern void z80_state_save(void *file); 48 | extern void z80_state_load(void *file); 49 | extern const char *z80_info(void *context, int regnum); 50 | extern unsigned z80_dasm(char *buffer, unsigned pc); 51 | 52 | #ifdef MAME_DEBUG 53 | extern unsigned DasmZ80(char *buffer, unsigned pc); 54 | #endif 55 | 56 | unsigned int cpu_readport16(unsigned int port); 57 | void cpu_writeport16(unsigned int port, unsigned int data); 58 | unsigned int cpu_readmem16(unsigned int address); 59 | void cpu_writemem16(unsigned int address, unsigned int data); 60 | 61 | #endif 62 | 63 | -------------------------------------------------------------------------------- /gp2/emu/dos/SEALINTF.H: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _SEALINTF_H_ 3 | #define _SEALINTF_H_ 4 | 5 | #define MAX_SOUND 4 6 | #define NUMVOICES 16 7 | #define MAX_STREAM_CHANNELS 6 8 | 9 | /* Function prototypes */ 10 | void osd_update_audio(void); 11 | void osd_set_mastervolume(int _attenuation); 12 | int msdos_init_sound(int *rate, int card); 13 | void msdos_shutdown_sound(void); 14 | void playstreamedsample(int channel,signed char *data,int len,int freq,int volume,int pan,int bits); 15 | void osd_play_streamed_sample_16(int channel,signed short *data,int len,int freq,int volume,int pan); 16 | 17 | #endif /* _SEALINTF_H_ */ 18 | -------------------------------------------------------------------------------- /gp2/emu/dos/config.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _CONFIG_H_ 3 | #define _CONFIG_H_ 4 | 5 | #define PATH_SIZE (0x100) 6 | #define TOKEN_LIST_SIZE (0x20) 7 | 8 | typedef struct 9 | { 10 | char *token; 11 | int value; 12 | }t_strint; 13 | 14 | typedef struct 15 | { 16 | int video_width; 17 | int video_height; 18 | int video_depth; 19 | int video_driver; 20 | 21 | int autores; 22 | int autores_w; 23 | int autores_h; 24 | 25 | int remap; 26 | int blur; 27 | int scanlines; 28 | int scale; 29 | 30 | int vsync; 31 | int throttle; 32 | int fps; 33 | int skip; 34 | 35 | int sound; 36 | int sndcard; 37 | int sndrate; 38 | int swap; 39 | 40 | int wave; 41 | char wavpath[PATH_SIZE]; 42 | 43 | int joy_driver; 44 | 45 | int split; /* 1= Split image at 2 megabit boundary */ 46 | int flip; /* 1= Bit-flip image */ 47 | int usa; /* 1= Set D6 of $1000 to indicate US machine */ 48 | int softres; /* 1= Allow RUN+SELECT */ 49 | } t_option; 50 | 51 | /* Global variables */ 52 | extern t_option option; 53 | extern t_strint video_driver_table[]; 54 | extern t_strint joy_driver_table[]; 55 | 56 | /* Function prototypes */ 57 | void do_config(char *file); 58 | int parse_file(char *filename, int *argc, char **argv); 59 | void parse_args(int argc, char **argv); 60 | void print_options(void); 61 | int check_bool(char *token); 62 | void set_option_defaults(void); 63 | 64 | #endif /* _CONFIG_H_ */ 65 | 66 | -------------------------------------------------------------------------------- /gp2/emu/dos/dos.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _DOS_H_ 3 | #define _DOS_H_ 4 | 5 | /* Function prototypes */ 6 | int load_file(char *filename, char *buf, int size); 7 | int save_file(char *filename, char *buf, int size); 8 | void dos_update_input(void); 9 | void dos_update_audio(void); 10 | void dos_update_palette(void); 11 | void dos_update_video(void); 12 | void init_machine(void); 13 | void trash_machine(void); 14 | void make_vdp_palette(void); 15 | void dos_change_mode(void); 16 | int check_key(int code); 17 | 18 | #endif /* _DOS_H_ */ 19 | 20 | -------------------------------------------------------------------------------- /gp2/emu/dos/error.c: -------------------------------------------------------------------------------- 1 | 2 | #include "osd.h" 3 | 4 | FILE *error_log; 5 | 6 | struct { 7 | int enabled; 8 | int verbose; 9 | FILE *log; 10 | } t_error; 11 | 12 | void error_init(void) 13 | { 14 | error_log = fopen("error.log","w"); 15 | } 16 | 17 | void error_shutdown(void) 18 | { 19 | if(error_log) fclose(error_log); 20 | } 21 | 22 | void error(char *format, ...) 23 | { 24 | va_list ap; 25 | va_start(ap, format); 26 | if(error_log) vfprintf(error_log, format, ap); 27 | va_end(ap); 28 | } 29 | 30 | -------------------------------------------------------------------------------- /gp2/emu/dos/error.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _ERROR_H_ 3 | #define _ERROR_H_ 4 | 5 | /* Global variables */ 6 | FILE *error_log; 7 | 8 | /* Function prototypes */ 9 | void error_init(void); 10 | void error_shutdown(void); 11 | void error(char *format, ...); 12 | 13 | #endif /* _ERROR_H_ */ 14 | -------------------------------------------------------------------------------- /gp2/emu/dos/osd.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _OSD_H_ 3 | #define _OSD_H_ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "shared.h" 13 | #include "dos.h" 14 | #include "config.h" 15 | #include "sealintf.h" 16 | #include "error.h" 17 | 18 | #endif /* _OSD_H_ */ 19 | -------------------------------------------------------------------------------- /gp2/emu/fileio.c: -------------------------------------------------------------------------------- 1 | 2 | #include "shared.h" 3 | 4 | /* 5 | Load a normal file, or ZIP/GZ archive. 6 | Returns NULL if an error occured. 7 | */ 8 | uint8 *load_archive(char *filename, int *file_size) 9 | { 10 | int size = 0; 11 | uint8 *buf = NULL; 12 | struct stat statbuf; 13 | 14 | FILE *gd = NULL; 15 | 16 | /* Open file */ 17 | gd = fopen(filename, "rb"); 18 | if(!gd) return (0); 19 | 20 | /* Get file size */ 21 | if (stat(filename, &statbuf) != 0) 22 | { return(0);} 23 | size= statbuf.st_size; 24 | 25 | /* Allocate file data buffer */ 26 | buf = malloc(size); 27 | if(!buf) 28 | { 29 | fclose(gd); 30 | return (0); 31 | } 32 | 33 | /* Read file data */ 34 | fread(buf,size,1,gd); 35 | 36 | /* Close file */ 37 | fclose(gd); 38 | 39 | /* Update file size and return pointer to file data */ 40 | *file_size = size; 41 | return (buf); 42 | } -------------------------------------------------------------------------------- /gp2/emu/fileio.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _FILEIO_H_ 3 | #define _FILEIO_H_ 4 | 5 | /* Global variables */ 6 | extern int cart_size; 7 | extern char cart_name[0x100]; 8 | 9 | /* Function prototypes */ 10 | uint8 *load_archive(char *filename, int *file_size); 11 | int load_cart(char *filename); 12 | 13 | #endif /* _FILEIO_H_ */ 14 | -------------------------------------------------------------------------------- /gp2/emu/gen_input.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Genesis Plus 1.2a 3 | * Peripheral Input Support 4 | * 5 | * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) 6 | * modified by Eke-Eke (compatibility fixes & additional code), GC/Wii port 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | * 22 | ****************************************************************************************/ 23 | 24 | #ifndef _GEN_INPUT_H_ 25 | #define _GEN_INPUT_H_ 26 | 27 | /* Max. number of devices */ 28 | #define MAX_DEVICES (8) 29 | 30 | #define MAX_INPUTS 4 31 | 32 | 33 | /* Device types */ 34 | #define DEVICE_3BUTTON (0x00) /* 3-button gamepad */ 35 | #define DEVICE_6BUTTON (0x01) /* 6-button gamepad */ 36 | #define DEVICE_LIGHTGUN (0x02) /* Sega Menacer or Konami Justifier */ 37 | #define DEVICE_MOUSE (0x03) /* Sega Mouse */ 38 | #define DEVICE_2BUTTON (0x04) /* 2-button gamepad (not supported) */ 39 | #define NO_DEVICE (0x0F) /* unconnected */ 40 | 41 | /* Input bitmasks */ 42 | #define INPUT_MODE (0x00000800) 43 | #define INPUT_Z (0x00000400) 44 | #define INPUT_Y (0x00000200) 45 | #define INPUT_X (0x00000100) 46 | #define INPUT_START (0x00000080) 47 | #define INPUT_C (0x00000040) 48 | #define INPUT_B (0x00000020) 49 | #define INPUT_A (0x00000010) 50 | #define INPUT_LEFT (0x00000008) 51 | #define INPUT_RIGHT (0x00000004) 52 | #define INPUT_DOWN (0x00000002) 53 | #define INPUT_UP (0x00000001) 54 | 55 | /* System IO ports */ 56 | #define NO_SYSTEM (0) /* Unconnected Port*/ 57 | #define SYSTEM_GAMEPAD (1) /* Single Gamepad */ 58 | #define SYSTEM_MOUSE (2) /* Sega Mouse */ 59 | #define SYSTEM_MENACER (3) /* Sega Menacer (port 2) */ 60 | #define SYSTEM_JUSTIFIER (4) /* Konami Justifier (port 2) */ 61 | #define SYSTEM_TEAMPLAYER (5) /* Sega TeamPlayer */ 62 | #define SYSTEM_WAYPLAY (6) /* EA 4-Way Play (use both ports) */ 63 | 64 | /* Players Inputs */ 65 | #define PLAYER_1A (0) 66 | #define PLAYER_1B (1) 67 | #define PLAYER_1C (2) 68 | #define PLAYER_1D (3) 69 | #define PLAYER_2A (4) 70 | #define PLAYER_2B (5) 71 | #define PLAYER_2C (6) 72 | #define PLAYER_2D (7) 73 | 74 | typedef struct 75 | { 76 | uint8 dev[MAX_DEVICES]; /* Can be any of the DEVICE_* values */ 77 | uint32 pad[MAX_DEVICES]; /* Can be any of the INPUT_* bitmasks */ 78 | uint8 padtype[MAX_DEVICES]; /* 3BUTTONS or 6BUTTONS gamepad */ 79 | uint8 system[2]; /* Can be any of the SYSTEM_* bitmasks */ 80 | uint8 max; /* maximum number of connected devices */ 81 | uint8 current; /* current PAD number (4WAYPLAY) */ 82 | int analog[3][2]; /* analog devices */ 83 | int x_offset; 84 | int y_offset; 85 | } t_input; 86 | 87 | /* Global variables */ 88 | extern t_input input; 89 | 90 | /* Function prototypes */ 91 | extern void input_reset (void); 92 | extern void input_update(void); 93 | extern void input_raz(void); 94 | 95 | /* Peripherals specific */ 96 | extern void mouse_write(uint32 data); 97 | extern uint32 mouse_read(void); 98 | extern uint32 menacer_read (void); 99 | extern uint32 justifier_read (void); 100 | extern uint32 gamepad_1_read (void); 101 | extern uint32 gamepad_2_read (void); 102 | extern void gamepad_1_write (uint32 data); 103 | extern void gamepad_2_write (uint32 data); 104 | extern uint32 wayplay_1_read (void); 105 | extern uint32 wayplay_2_read (void); 106 | extern void wayplay_1_write (uint32 data); 107 | extern void wayplay_2_write (uint32 data); 108 | extern uint32 teamplayer_1_read (void); 109 | extern uint32 teamplayer_2_read (void); 110 | extern void teamplayer_1_write (uint32 data); 111 | extern void teamplayer_2_write (uint32 data); 112 | extern uint32 jcart_read(uint32 address); 113 | extern void jcart_write(uint32 address, uint32 data); 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /gp2/emu/gen_io.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Genesis Plus 1.2a 3 | * I/O Chip 4 | * 5 | * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) 6 | * modified by Eke-Eke (compatibility fixes & additional code), GC/Wii port 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | * 22 | ****************************************************************************************/ 23 | 24 | #ifndef _GEN_IO_H_ 25 | #define _GEN_IO_H_ 26 | 27 | #define REGION_JAPAN_NTSC 0x00 28 | #define REGION_JAPAN_PAL 0x40 29 | #define REGION_USA 0x80 30 | #define REGION_EUROPE 0xC0 31 | 32 | /* Global variables */ 33 | extern uint8 io_reg[0x10]; 34 | extern uint8 region_code; 35 | extern uint8 pad_type; 36 | 37 | /* Function prototypes */ 38 | extern void io_reset(void); 39 | extern void io_write(uint32 offset, uint32 value); 40 | extern uint32 io_read(uint32 offset); 41 | 42 | #endif /* _IO_H_ */ 43 | 44 | -------------------------------------------------------------------------------- /gp2/emu/genesis.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | 20 | #include "shared.h" 21 | 22 | uint8 cart_rom[0x400000]; /* Cartridge ROM */ 23 | uint8 work_ram[0x10000]; /* 68K work RAM */ 24 | uint8 zram[0x2000]; /* Z80 work RAM */ 25 | uint8 zbusreq; /* /BUSREQ from Z80 */ 26 | uint8 zreset; /* /RESET to Z80 */ 27 | uint8 zbusack; /* /BUSACK to Z80 */ 28 | uint8 zirq; /* /IRQ to Z80 */ 29 | uint32 zbank; /* Address of Z80 bank window */ 30 | uint8 gen_running; 31 | 32 | /*--------------------------------------------------------------------------*/ 33 | /* Init, reset, shutdown functions */ 34 | /*--------------------------------------------------------------------------*/ 35 | 36 | void gen_init(void) 37 | { 38 | sound_init(); 39 | memset(&snd, 0, sizeof(snd)); 40 | 41 | bswap(cart_rom, 0x400000); 42 | m68k_set_cpu_type(M68K_CPU_TYPE_68000); 43 | m68k_pulse_reset(); 44 | //error("PC:%08X\tSP:%08X\n", m68k_get_reg(NULL,M68K_REG_PC), m68k_get_reg(NULL,M68K_REG_SP)); 45 | gen_running = 1; 46 | } 47 | 48 | void gen_reset(void) 49 | { 50 | /* Clear RAM */ 51 | memset(work_ram, 0, sizeof(work_ram)); 52 | memset(zram, 0, sizeof(zram)); 53 | 54 | gen_running = 1; 55 | zreset = 0; /* Z80 is reset */ 56 | zbusreq = 0; /* Z80 has control of the Z bus */ 57 | zbusack = 1; /* Z80 is busy using the Z bus */ 58 | zbank = 0; /* Assume default bank is 000000-007FFF */ 59 | zirq = 0; /* No interrupts occuring */ 60 | 61 | io_reset(); 62 | 63 | /* Reset the 68000 emulator */ 64 | m68k_pulse_reset(); 65 | //error("PC:%08X\tSP:%08X\n", m68k_get_reg(NULL,M68K_REG_PC), m68k_get_reg(NULL,M68K_REG_SP)); 66 | z80_reset(0); 67 | z80_set_irq_callback(z80_irq_callback); 68 | } 69 | 70 | void gen_shutdown(void) 71 | { 72 | int i; 73 | 74 | /* Print 68K and Z80 state */ 75 | //error("\n"); 76 | //error("\nPC:%08X\tSP:%08X\tSR:%04X\n", m68k_get_reg(NULL,M68K_REG_PC), m68k_get_reg(NULL,M68K_REG_SP), m68k_get_reg(NULL, M68K_REG_SR)); 77 | /*for(i=0;i<8;i++) 78 | { 79 | error("D%d:%08X\tA%d:%08X\n", 80 | i, m68k_get_reg(NULL, M68K_REG_D0+i), 81 | i, m68k_get_reg(NULL, M68K_REG_A0+i)); 82 | } 83 | /* 84 | error("\n"); 85 | error("PC:%04X\tSP:%04X\n", z80_get_reg(Z80_PC), z80_get_reg(Z80_SP)); 86 | error("AF:%04X\tAF:%04X\n", z80_get_reg(Z80_AF), z80_get_reg(Z80_AF2)); 87 | error("BC:%04X\tBC:%04X\n", z80_get_reg(Z80_BC), z80_get_reg(Z80_BC2)); 88 | error("DE:%04X\tDE:%04X\n", z80_get_reg(Z80_DE), z80_get_reg(Z80_DE2)); 89 | error("HL:%04X\tHL:%04X\n", z80_get_reg(Z80_HL), z80_get_reg(Z80_HL2)); 90 | error("IX:%04X\tIY:%04X\n", z80_get_reg(Z80_IX), z80_get_reg(Z80_IY)); 91 | error("\n"); 92 | */ 93 | } 94 | 95 | /*--------------------------------------------------------------------------*/ 96 | /* Bus controller chip functions */ 97 | /*--------------------------------------------------------------------------*/ 98 | 99 | int gen_busack_r(void) 100 | { 101 | return (zbusack & 1); 102 | } 103 | 104 | void gen_busreq_w(int state) 105 | { 106 | zbusreq = (state & 1); 107 | zbusack = 1 ^ (zbusreq & zreset); 108 | 109 | if(zbusreq == 0 && zreset == 1) 110 | { 111 | z80_execute(32); 112 | } 113 | } 114 | 115 | void gen_reset_w(int state) 116 | { 117 | zreset = (state & 1); 118 | zbusack = 1 ^ (zbusreq & zreset); 119 | 120 | if(zreset == 0) 121 | { 122 | if(snd.enabled) 123 | { 124 | YM2612ResetChip(0); 125 | } 126 | 127 | z80_reset(0); 128 | z80_set_irq_callback(z80_irq_callback); 129 | } 130 | } 131 | 132 | 133 | void gen_bank_w(int state) 134 | { 135 | zbank = ((zbank >> 1) | ((state & 1) << 23)) & 0xFF8000; 136 | } 137 | 138 | 139 | 140 | int z80_irq_callback(int param) 141 | { 142 | zirq = 0; 143 | z80_set_irq_line(0, CLEAR_LINE); 144 | return 0xFF; 145 | } 146 | 147 | int vdp_int_ack_callback(int int_level) 148 | { 149 | switch(int_level) 150 | { 151 | case 4: 152 | hint_pending = 0; 153 | break; 154 | 155 | case 6: 156 | status &= ~0x0080; 157 | vint_pending = 0; 158 | break; 159 | } 160 | 161 | return M68K_INT_ACK_AUTOVECTOR; 162 | } 163 | 164 | 165 | void bswap(uint8 *mem, int length) 166 | { 167 | int i; 168 | for(i = 0; i < length; i += 2) 169 | { 170 | uint8 temp = mem[i+0]; 171 | mem[i+0] = mem[i+1]; 172 | mem[i+1] = temp; 173 | } 174 | } 175 | 176 | -------------------------------------------------------------------------------- /gp2/emu/genesis.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _GENESIS_H_ 3 | #define _GENESIS_H_ 4 | 5 | /* Global variables */ 6 | extern uint8 cart_rom[0x400000]; 7 | extern uint8 work_ram[0x10000]; 8 | extern uint8 zram[0x2000]; 9 | extern uint8 zbusreq; 10 | extern uint8 zbusack; 11 | extern uint8 zreset; 12 | extern uint8 zirq; 13 | extern uint32 zbank; 14 | extern uint8 gen_running; 15 | 16 | /* Function prototypes */ 17 | void gen_init(void); 18 | void gen_reset(void); 19 | void gen_shutdown(void); 20 | int gen_busack_r(void); 21 | void gen_busreq_w(int state); 22 | void gen_reset_w(int state); 23 | void gen_bank_w(int state); 24 | void bswap(uint8 *mem, int length); 25 | int z80_irq_callback(int param); 26 | void m68k_irq_ack_callback(int int_level); 27 | 28 | #endif /* _GEN_H_ */ 29 | 30 | -------------------------------------------------------------------------------- /gp2/emu/hcnt.h: -------------------------------------------------------------------------------- 1 | uint8 cycle2hc32[488] = 2 | { 3 | 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x05, 4 | 0x05, 0x05, 0x06, 0x06, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08, 0x09, 0x09, 0x09, 0x0A, 0x0A, 0x0A, 5 | 0x0B, 0x0B, 0x0B, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0E, 0x0E, 0x0E, 0x0F, 0x0F, 0x0F, 0x10, 0x10, 6 | 0x10, 0x11, 0x11, 0x11, 0x12, 0x12, 0x12, 0x13, 0x13, 0x13, 0x14, 0x14, 0x15, 0x15, 0x15, 0x16, 7 | 0x16, 0x16, 0x17, 0x17, 0x17, 0x18, 0x18, 0x18, 0x19, 0x19, 0x19, 0x1A, 0x1A, 0x1B, 0x1B, 0x1B, 8 | 0x1C, 0x1C, 0x1C, 0x1D, 0x1D, 0x1D, 0x1E, 0x1E, 0x1E, 0x1F, 0x1F, 0x1F, 0x20, 0x20, 0x20, 0x21, 9 | 0x21, 0x22, 0x22, 0x22, 0x23, 0x23, 0x23, 0x24, 0x24, 0x24, 0x25, 0x25, 0x25, 0x26, 0x26, 0x26, 10 | 0x27, 0x27, 0x27, 0x28, 0x28, 0x29, 0x29, 0x29, 0x2A, 0x2A, 0x2A, 0x2B, 0x2B, 0x2B, 0x2C, 0x2C, 11 | 0x2C, 0x2D, 0x2D, 0x2D, 0x2E, 0x2E, 0x2F, 0x2F, 0x2F, 0x30, 0x30, 0x30, 0x31, 0x31, 0x31, 0x32, 12 | 0x32, 0x32, 0x33, 0x33, 0x33, 0x34, 0x34, 0x34, 0x35, 0x35, 0x36, 0x36, 0x36, 0x37, 0x37, 0x37, 13 | 0x38, 0x38, 0x38, 0x39, 0x39, 0x39, 0x3A, 0x3A, 0x3A, 0x3B, 0x3B, 0x3B, 0x3C, 0x3C, 0x3D, 0x3D, 14 | 0x3D, 0x3E, 0x3E, 0x3E, 0x3F, 0x3F, 0x3F, 0x40, 0x40, 0x40, 0x41, 0x41, 0x41, 0x42, 0x42, 0x42, 15 | 0x43, 0x43, 0x44, 0x44, 0x44, 0x45, 0x45, 0x45, 0x46, 0x46, 0x46, 0x47, 0x47, 0x47, 0x48, 0x48, 16 | 0x48, 0x49, 0x49, 0x4A, 0x4A, 0x4A, 0x4B, 0x4B, 0x4B, 0x4C, 0x4C, 0x4C, 0x4D, 0x4D, 0x4D, 0x4E, 17 | 0x4E, 0x4E, 0x4F, 0x4F, 0x4F, 0x50, 0x50, 0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x53, 0x53, 0x53, 18 | 0x54, 0x54, 0x54, 0x55, 0x55, 0x55, 0x56, 0x56, 0x56, 0x57, 0x57, 0x58, 0x58, 0x58, 0x59, 0x59, 19 | 0x59, 0x5A, 0x5A, 0x5A, 0x5B, 0x5B, 0x5B, 0x5C, 0x5C, 0x5C, 0x5D, 0x5D, 0x5E, 0x5E, 0x5E, 0x5F, 20 | 0x5F, 0x5F, 0x60, 0x60, 0x60, 0x61, 0x61, 0x61, 0x62, 0x62, 0x62, 0x63, 0x63, 0x63, 0x64, 0x64, 21 | 0x65, 0x65, 0x65, 0x66, 0x66, 0x66, 0x67, 0x67, 0x67, 0x68, 0x68, 0x68, 0x69, 0x69, 0x69, 0x6A, 22 | 0x6A, 0x6A, 0x6B, 0x6B, 0x6C, 0x6C, 0x6C, 0x6D, 0x6D, 0x6D, 0x6E, 0x6E, 0x6E, 0x6F, 0x6F, 0x6F, 23 | 0x70, 0x70, 0x70, 0x71, 0x71, 0x72, 0x72, 0x72, 0x73, 0x73, 0x73, 0x74, 0x74, 0x74, 0x75, 0x75, 24 | 0x75, 0x76, 0x76, 0x76, 0x77, 0x77, 0x77, 0x78, 0x78, 0x79, 0x79, 0x79, 0x7A, 0x7A, 0x7A, 0x7B, 25 | 0x7B, 0x7B, 0x7C, 0x7C, 0x7C, 0x7D, 0x7D, 0x7D, 0x7E, 0x7E, 0x7E, 0x7F, 0x7F, 0x80, 0x80, 0x80, 26 | 0x81, 0x81, 0x81, 0x82, 0x82, 0x82, 0x83, 0x83, 0x83, 0x84, 0x84, 0x84, 0x85, 0x85, 0x85, 0x86, 27 | 0x86, 0x87, 0x87, 0x87, 0x88, 0x88, 0x88, 0x89, 0x89, 0x89, 0x8A, 0x8A, 0x8A, 0x8B, 0x8B, 0x8B, 28 | 0x8C, 0x8C, 0x8D, 0x8D, 0x8D, 0x8E, 0x8E, 0x8E, 0x8F, 0x8F, 0x8F, 0x90, 0x90, 0x90, 0x91, 0x91, 29 | 0x91, 0x92, 0x92, 0x92, 0x93, 0x93, 0xE9, 0xE9, 0xE9, 0xEA, 0xEA, 0xEA, 0xEB, 0xEB, 0xEB, 0xEC, 30 | 0xEC, 0xEC, 0xED, 0xED, 0xED, 0xEE, 0xEE, 0xEE, 0xEF, 0xEF, 0xF0, 0xF0, 0xF0, 0xF1, 0xF1, 0xF1, 31 | 0xF2, 0xF2, 0xF2, 0xF3, 0xF3, 0xF3, 0xF4, 0xF4, 0xF4, 0xF5, 0xF5, 0xF6, 0xF6, 0xF6, 0xF7, 0xF7, 32 | 0xF7, 0xF8, 0xF8, 0xF8, 0xF9, 0xF9, 0xF9, 0xFA, 0xFA, 0xFA, 0xFB, 0xFB, 0xFB, 0xFC, 0xFC, 0xFD, 33 | 0xFD, 0xFD, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 34 | }; 35 | uint8 cycle2hc40[488] = 36 | { 37 | 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x03, 0x03, 0x04, 0x04, 0x05, 0x05, 0x06, 0x06, 38 | 0x06, 0x07, 0x07, 0x08, 0x08, 0x09, 0x09, 0x09, 0x0A, 0x0A, 0x0B, 0x0B, 0x0C, 0x0C, 0x0C, 0x0D, 39 | 0x0D, 0x0E, 0x0E, 0x0F, 0x0F, 0x10, 0x10, 0x10, 0x11, 0x11, 0x12, 0x12, 0x13, 0x13, 0x13, 0x14, 40 | 0x14, 0x15, 0x15, 0x16, 0x16, 0x16, 0x17, 0x17, 0x18, 0x18, 0x19, 0x19, 0x19, 0x1A, 0x1A, 0x1B, 41 | 0x1B, 0x1C, 0x1C, 0x1C, 0x1D, 0x1D, 0x1E, 0x1E, 0x1F, 0x1F, 0x20, 0x20, 0x20, 0x21, 0x21, 0x22, 42 | 0x22, 0x23, 0x23, 0x23, 0x24, 0x24, 0x25, 0x25, 0x26, 0x26, 0x26, 0x27, 0x27, 0x28, 0x28, 0x29, 43 | 0x29, 0x29, 0x2A, 0x2A, 0x2B, 0x2B, 0x2C, 0x2C, 0x2D, 0x2D, 0x2D, 0x2E, 0x2E, 0x2F, 0x2F, 0x30, 44 | 0x30, 0x30, 0x31, 0x31, 0x32, 0x32, 0x33, 0x33, 0x33, 0x34, 0x34, 0x35, 0x35, 0x36, 0x36, 0x36, 45 | 0x37, 0x37, 0x38, 0x38, 0x39, 0x39, 0x39, 0x3A, 0x3A, 0x3B, 0x3B, 0x3C, 0x3C, 0x3D, 0x3D, 0x3D, 46 | 0x3E, 0x3E, 0x3F, 0x3F, 0x40, 0x40, 0x40, 0x41, 0x41, 0x42, 0x42, 0x43, 0x43, 0x43, 0x44, 0x44, 47 | 0x45, 0x45, 0x46, 0x46, 0x46, 0x47, 0x47, 0x48, 0x48, 0x49, 0x49, 0x4A, 0x4A, 0x4A, 0x4B, 0x4B, 48 | 0x4C, 0x4C, 0x4D, 0x4D, 0x4D, 0x4E, 0x4E, 0x4F, 0x4F, 0x50, 0x50, 0x50, 0x51, 0x51, 0x52, 0x52, 49 | 0x53, 0x53, 0x53, 0x54, 0x54, 0x55, 0x55, 0x56, 0x56, 0x56, 0x57, 0x57, 0x58, 0x58, 0x59, 0x59, 50 | 0x5A, 0x5A, 0x5A, 0x5B, 0x5B, 0x5C, 0x5C, 0x5D, 0x5D, 0x5D, 0x5E, 0x5E, 0x5F, 0x5F, 0x60, 0x60, 51 | 0x60, 0x61, 0x61, 0x62, 0x62, 0x63, 0x63, 0x63, 0x64, 0x64, 0x65, 0x65, 0x66, 0x66, 0x67, 0x67, 52 | 0x67, 0x68, 0x68, 0x69, 0x69, 0x6A, 0x6A, 0x6A, 0x6B, 0x6B, 0x6C, 0x6C, 0x6D, 0x6D, 0x6D, 0x6E, 53 | 0x6E, 0x6F, 0x6F, 0x70, 0x70, 0x70, 0x71, 0x71, 0x72, 0x72, 0x73, 0x73, 0x73, 0x74, 0x74, 0x75, 54 | 0x75, 0x76, 0x76, 0x77, 0x77, 0x77, 0x78, 0x78, 0x79, 0x79, 0x7A, 0x7A, 0x7A, 0x7B, 0x7B, 0x7C, 55 | 0x7C, 0x7D, 0x7D, 0x7D, 0x7E, 0x7E, 0x7F, 0x7F, 0x80, 0x80, 0x80, 0x81, 0x81, 0x82, 0x82, 0x83, 56 | 0x83, 0x84, 0x84, 0x84, 0x85, 0x85, 0x86, 0x86, 0x87, 0x87, 0x87, 0x88, 0x88, 0x89, 0x89, 0x8A, 57 | 0x8A, 0x8A, 0x8B, 0x8B, 0x8C, 0x8C, 0x8D, 0x8D, 0x8D, 0x8E, 0x8E, 0x8F, 0x8F, 0x90, 0x90, 0x90, 58 | 0x91, 0x91, 0x92, 0x92, 0x93, 0x93, 0x94, 0x94, 0x94, 0x95, 0x95, 0x96, 0x96, 0x97, 0x97, 0x97, 59 | 0x98, 0x98, 0x99, 0x99, 0x9A, 0x9A, 0x9A, 0x9B, 0x9B, 0x9C, 0x9C, 0x9D, 0x9D, 0x9D, 0x9E, 0x9E, 60 | 0x9F, 0x9F, 0xA0, 0xA0, 0xA1, 0xA1, 0xA1, 0xA2, 0xA2, 0xA3, 0xA3, 0xA4, 0xA4, 0xA4, 0xA5, 0xA5, 61 | 0xA6, 0xA6, 0xA7, 0xA7, 0xA7, 0xA8, 0xA8, 0xA9, 0xA9, 0xAA, 0xAA, 0xAA, 0xAB, 0xAB, 0xAC, 0xAC, 62 | 0xAD, 0xAD, 0xAD, 0xAE, 0xAE, 0xAF, 0xAF, 0xB0, 0xB0, 0xB1, 0xB1, 0xB1, 0xB2, 0xB2, 0xB3, 0xB3, 63 | 0xB4, 0xB4, 0xB4, 0xB5, 0xB5, 0xB6, 0xB6, 0xE4, 0xE4, 0xE4, 0xE5, 0xE5, 0xE6, 0xE6, 0xE7, 0xE7, 64 | 0xE7, 0xE8, 0xE8, 0xE9, 0xE9, 0xEA, 0xEA, 0xEB, 0xEB, 0xEB, 0xEC, 0xEC, 0xED, 0xED, 0xEE, 0xEE, 65 | 0xEE, 0xEF, 0xEF, 0xF0, 0xF0, 0xF1, 0xF1, 0xF1, 0xF2, 0xF2, 0xF3, 0xF3, 0xF4, 0xF4, 0xF4, 0xF5, 66 | 0xF5, 0xF6, 0xF6, 0xF7, 0xF7, 0xF7, 0xF8, 0xF8, 0xF9, 0xF9, 0xFA, 0xFA, 0xFB, 0xFB, 0xFB, 0xFC, 67 | 0xFC, 0xFD, 0xFD, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 68 | }; 69 | -------------------------------------------------------------------------------- /gp2/emu/io.h: -------------------------------------------------------------------------------- 1 | #ifndef _IO_H_ 2 | #define _IO_H_ 3 | 4 | /* 5 | 6 | void io_reset(void); 7 | void io_set_version(int export, int pal, int fdd, int n); 8 | 9 | 10 | */ 11 | 12 | typedef struct 13 | { 14 | void (*data_w)(uint8 data); 15 | uint8 (*data_r)(void); 16 | } port_t; 17 | 18 | typedef struct 19 | { 20 | uint8 state; 21 | } t_input_3b; 22 | 23 | /* Global variables */ 24 | extern port_t port[3]; 25 | extern uint8 io_reg[0x10]; 26 | 27 | /* Function prototypes */ 28 | extern void io_reset(void); 29 | extern void gen_io_w(int offset, int value); 30 | extern int gen_io_r(int offset); 31 | extern uint8 pad_2b_r(void); 32 | extern uint8 device_3b_r(void); 33 | extern void device_3b_w(uint8 data); 34 | 35 | #endif /* _IO_H_ */ 36 | 37 | -------------------------------------------------------------------------------- /gp2/emu/loadrom.c: -------------------------------------------------------------------------------- 1 | 2 | #include "shared.h" 3 | 4 | static uint8 block[0x4000]; 5 | int rom_size=0; 6 | char rom_filename[256]={""}; 7 | 8 | void deinterleave_block(uint8 *src) 9 | { 10 | int i; 11 | memcpy(block, src, 0x4000); 12 | for(i = 0; i < 0x2000; i += 1) 13 | { 14 | src[i*2+0] = block[0x2000 + (i)]; 15 | src[i*2+1] = block[0x0000 + (i)]; 16 | } 17 | } 18 | 19 | int load_rom(char *filename) 20 | { 21 | int size, offset = 0; 22 | uint8 header[0x200]; 23 | uint8 *ptr; 24 | rom_size=0; 25 | 26 | ptr = load_archive(filename, &size); 27 | if(!ptr) return (0); 28 | 29 | if((size / 512) & 1) 30 | { 31 | int i; 32 | 33 | size -= 512; 34 | offset += 512; 35 | 36 | memcpy(header, ptr, 512); 37 | 38 | for(i = 0; i < (size / 0x4000); i += 1) 39 | { 40 | deinterleave_block(ptr + offset + (i * 0x4000)); 41 | } 42 | } 43 | 44 | memset(cart_rom, 0, 0x400000); 45 | if(size > 0x400000) size = 0x400000; 46 | memcpy(cart_rom, ptr + offset, size); 47 | 48 | /* Free allocated file data */ 49 | free(ptr); 50 | 51 | rom_size=size; 52 | strcpy(rom_filename,filename); 53 | 54 | return (1); 55 | } 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /gp2/emu/loadrom.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _LOADROM_H_ 3 | #define _LOADROM_H_ 4 | 5 | /* Function prototypes */ 6 | void deinterleave_block(uint8 *src); 7 | int load_rom(char *filename); 8 | 9 | #endif /* _LOADROM_H_ */ 10 | 11 | -------------------------------------------------------------------------------- /gp2/emu/m68k.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pascalorama/megadrive-studio/8289e8ce63f6c4584f57ec6afc27f0361809ba0e/gp2/emu/m68k.rar -------------------------------------------------------------------------------- /gp2/emu/m68k/MAKE.BAT: -------------------------------------------------------------------------------- 1 | gcc m68kmake.c -o m68kmake.exe 2 | m68kmake 3 | gcc -c m68kcpu.c -o m68kcpu.o -O6 -march=pentium -fomit-frame-pointer -DGENESIS_HACKS="1" 4 | gcc -c m68kops.c -o m68kops.o -O6 -march=pentium -fomit-frame-pointer -DGENESIS_HACKS="1" 5 | gcc -c m68kopac.c -o m68kopac.o -O6 -march=pentium -fomit-frame-pointer -DGENESIS_HACKS="1" 6 | gcc -c m68kopdm.c -o m68kopdm.o -O6 -march=pentium -fomit-frame-pointer -DGENESIS_HACKS="1" 7 | gcc -c m68kopnz.c -o m68kopnz.o -O6 -march=pentium -fomit-frame-pointer -DGENESIS_HACKS="1" 8 | ar rs m68k.oa m68kcpu.o m68kops.o m68kopac.o m68kopdm.o m68kopnz.o 9 | -------------------------------------------------------------------------------- /gp2/emu/m68k/clean.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | del *.o 3 | del *.oa 4 | del *.exe 5 | -------------------------------------------------------------------------------- /gp2/emu/m68k/debug.txt: -------------------------------------------------------------------------------- 1 | << Megadrive Debug >> 2 | LoadRom Fct loaded 3 | DisAsm Fct loaded 4 | InitEmulator Fct loaded 5 | RunEmulator Fct loaded 6 | << start running >> 7 | 518:tst.l $a10008.l 8 | 522:bne 210 9 | 528:tst.w $a1000c.l 10 | 532:bne 296 11 | Press any key to continue -------------------------------------------------------------------------------- /gp2/emu/m68k/m68k.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pascalorama/megadrive-studio/8289e8ce63f6c4584f57ec6afc27f0361809ba0e/gp2/emu/m68k/m68k.rar -------------------------------------------------------------------------------- /gp2/emu/macros.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _MACROS_H_ 3 | #define _MACROS_H_ 4 | 5 | 6 | #define READ_BYTE(BASE, ADDR) (BASE)[(ADDR)^1] 7 | #define READ_WORD(BASE, ADDR) (((BASE)[(ADDR)+1]<<8) | \ 8 | (BASE)[(ADDR)]) 9 | #define READ_LONG(BASE, ADDR) (((BASE)[(ADDR)+1]<<24) | \ 10 | ((BASE)[(ADDR)+0]<<16) | \ 11 | ((BASE)[(ADDR)+3]<<8) | \ 12 | (BASE)[(ADDR)+2]) 13 | 14 | #define WRITE_BYTE(BASE, ADDR, VAL) (BASE)[(ADDR)^1] = (VAL)&0xff 15 | #define WRITE_WORD(BASE, ADDR, VAL) (BASE)[(ADDR)+1] = ((VAL)>>8) & 0xff; \ 16 | (BASE)[ADDR] = (VAL)&0xff 17 | #define WRITE_LONG(BASE, ADDR, VAL) (BASE)[(ADDR)+1] = ((VAL)>>24) & 0xff; \ 18 | (BASE)[(ADDR)+0] = ((VAL)>>16)&0xff; \ 19 | (BASE)[(ADDR)+3] = ((VAL)>>8)&0xff; \ 20 | (BASE)[(ADDR)+2] = (VAL)&0xff 21 | 22 | 23 | 24 | #if 0 25 | 26 | #define READ_BYTE(BASE, ADDR) (BASE)[ADDR] 27 | #define READ_WORD(BASE, ADDR) (((BASE)[ADDR]<<8) | \ 28 | (BASE)[(ADDR)+1]) 29 | #define READ_LONG(BASE, ADDR) (((BASE)[ADDR]<<24) | \ 30 | ((BASE)[(ADDR)+1]<<16) | \ 31 | ((BASE)[(ADDR)+2]<<8) | \ 32 | (BASE)[(ADDR)+3]) 33 | 34 | #define WRITE_BYTE(BASE, ADDR, VAL) (BASE)[ADDR] = (VAL)&0xff 35 | #define WRITE_WORD(BASE, ADDR, VAL) (BASE)[ADDR] = ((VAL)>>8) & 0xff; \ 36 | (BASE)[(ADDR)+1] = (VAL)&0xff 37 | #define WRITE_LONG(BASE, ADDR, VAL) (BASE)[ADDR] = ((VAL)>>24) & 0xff; \ 38 | (BASE)[(ADDR)+1] = ((VAL)>>16)&0xff; \ 39 | (BASE)[(ADDR)+2] = ((VAL)>>8)&0xff; \ 40 | (BASE)[(ADDR)+3] = (VAL)&0xff 41 | #endif 42 | 43 | 44 | #endif /* _MACROS_H_ */ 45 | 46 | -------------------------------------------------------------------------------- /gp2/emu/make.bat: -------------------------------------------------------------------------------- 1 | @make.exe -f makefile.mgw %1 2 | -------------------------------------------------------------------------------- /gp2/emu/makefile.dj2: -------------------------------------------------------------------------------- 1 | # MekaDrive - Sega Mega Drive emulator 2 | # (c) 1999, 2000, 2001, 2002, 2003 Charles MacDonald 3 | 4 | # -DLSB_FIRST - Leave undefined for big-endian processors. 5 | # -DDOS - Enable DOS/x86 specific code. 6 | # -DDEBUG - Enable debugging code 7 | # -DX86_ASM - Enable inline x86 assembly code in Z80 emulator 8 | 9 | CC = gcc 10 | AS = nasm -f coff 11 | LDFLAGS = 12 | FLAGS = -I. -Icpu -Idos -Isound \ 13 | -Werror -Wall \ 14 | -O6 -mcpu=pentium -fomit-frame-pointer \ 15 | -DLSB_FIRST -DX86_ASM -DDOS 16 | 17 | LIBS = -lalleg -laudio -lz obj/m68k.oa 18 | 19 | OBJ = obj/z80.oa \ 20 | obj/genesis.o \ 21 | obj/vdp.o \ 22 | obj/render.o \ 23 | obj/system.o \ 24 | obj/unzip.o \ 25 | obj/fileio.o \ 26 | obj/loadrom.o \ 27 | obj/io.o \ 28 | obj/mem68k.o \ 29 | obj/memz80.o \ 30 | obj/membnk.o \ 31 | obj/memvdp.o 32 | 33 | OBJ += obj/sound.o \ 34 | obj/fm.o \ 35 | obj/sn76496.o 36 | 37 | OBJ += obj/dos.o \ 38 | obj/sealintf.o \ 39 | obj/config.o \ 40 | obj/error.o 41 | 42 | EXE = gen.exe 43 | 44 | all : $(EXE) 45 | 46 | $(EXE) : $(OBJ) 47 | $(CC) -o $(EXE) $(OBJ) $(LIBS) $(LDFLAGS) 48 | 49 | obj/%.oa : cpu/%.c cpu/%.h 50 | $(CC) -c $< -o $@ $(FLAGS) 51 | 52 | obj/%.o : %.c %.h 53 | $(CC) -c $< -o $@ $(FLAGS) 54 | 55 | obj/%.o : asm/%.s 56 | $(AS) $< -o $@ 57 | 58 | obj/%.o : sound/%.c sound/%.h 59 | $(CC) -c $< -o $@ $(FLAGS) 60 | 61 | obj/%.o : cpu/%.c cpu/%.h 62 | $(CC) -c $< -o $@ $(FLAGS) 63 | 64 | obj/%.o : dos/%.c dos/%.h 65 | $(CC) -c $< -o $@ $(FLAGS) 66 | 67 | pack : 68 | strip $(EXE) 69 | upx -1 $(EXE) 70 | 71 | clean : 72 | rm -f obj/*.o 73 | rm -f *.bak 74 | rm -f *.exe 75 | rm -f *.log 76 | rm -f *.wav 77 | rm -f *.zip 78 | cleancpu : 79 | rm -f obj/z80.oa 80 | 81 | makedir : 82 | mkdir obj 83 | 84 | archive: 85 | pk -dir -add -max \ 86 | -excl=rom -excl=test \ 87 | mdsrc.zip *.* 88 | 89 | # 90 | # end of makefile 91 | # 92 | -------------------------------------------------------------------------------- /gp2/emu/makefile.mgw: -------------------------------------------------------------------------------- 1 | # Genesis Plus - Sega Mega Drive emulator 2 | # (c) 1999, 2000, 2001, 2002, 2003 Charles MacDonald 3 | 4 | # -DLSB_FIRST - Leave undefined for big-endian processors. 5 | # -DDEBUG - Enable debugging code 6 | # -DX86_ASM - Enable inline x86 assembly code in Z80 emulator 7 | 8 | CC = gcc 9 | AS = nasm -f coff 10 | LDFLAGS = 11 | FLAGS = -I. -Icpu -Iwin -Isound \ 12 | -Id:/sdl/include \ 13 | -Werror -Wall \ 14 | -DLSB_FIRST -DX86_ASM \ 15 | -O6 -march=pentium -fomit-frame-pointer 16 | 17 | LIBS = -lz -lm -lmingw32 -Ld:/sdl/lib -lSDLmain -lSDL obj/m68k.oa 18 | 19 | OBJ = obj/z80.oa \ 20 | obj/genesis.o \ 21 | obj/vdp.o \ 22 | obj/render.o \ 23 | obj/system.o \ 24 | obj/unzip.o \ 25 | obj/fileio.o \ 26 | obj/loadrom.o \ 27 | obj/io.o \ 28 | obj/mem68k.o \ 29 | obj/memz80.o \ 30 | obj/membnk.o \ 31 | obj/memvdp.o 32 | 33 | OBJ += obj/sound.o \ 34 | obj/fm.o \ 35 | obj/sn76496.o 36 | 37 | OBJ += obj/main.o \ 38 | obj/error.o 39 | 40 | EXE = gen.exe 41 | 42 | all : $(EXE) 43 | 44 | $(EXE) : $(OBJ) shared.h 45 | $(CC) -o $(EXE) $(OBJ) $(LIBS) $(LDFLAGS) 46 | 47 | obj/%.oa : cpu/%.c cpu/%.h 48 | $(CC) -c $< -o $@ $(FLAGS) 49 | 50 | obj/%.o : %.c %.h 51 | $(CC) -c $< -o $@ $(FLAGS) 52 | 53 | obj/%.o : win/%.s 54 | $(AS) $< -o $@ 55 | 56 | obj/%.o : sound/%.c sound/%.h 57 | $(CC) -c $< -o $@ $(FLAGS) 58 | 59 | obj/%.o : cpu/%.c cpu/%.h 60 | $(CC) -c $< -o $@ $(FLAGS) 61 | 62 | obj/%.o : win/%.c win/%.h 63 | $(CC) -c $< -o $@ $(FLAGS) 64 | 65 | pack : 66 | strip $(EXE) 67 | upx -1 $(EXE) 68 | 69 | clean : 70 | rm -f obj/*.o 71 | rm -f *.bak 72 | rm -f *.exe 73 | rm -f *.log 74 | rm -f *.wav 75 | rm -f *.zip 76 | cleancpu : 77 | rm -f obj/z80.oa 78 | 79 | makedir : 80 | mkdir obj 81 | 82 | archive: 83 | pk -add -max -excl=bak -excl=out \ 84 | -excl=test -excl=obj mdsrc.zip -dir=current 85 | 86 | # 87 | # end of makefile 88 | # 89 | -------------------------------------------------------------------------------- /gp2/emu/mem68k.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _MEM68K_H_ 3 | #define _MEM68K_H_ 4 | 5 | /* Function prototypes */ 6 | unsigned int m68k_read_bus_8(unsigned int address); 7 | unsigned int m68k_read_bus_16(unsigned int address); 8 | void m68k_unused_w(unsigned int address, unsigned int value); 9 | 10 | void m68k_lockup_w_8(unsigned int address, unsigned int value); 11 | void m68k_lockup_w_16(unsigned int address, unsigned int value); 12 | unsigned int m68k_lockup_r_8(unsigned int address); 13 | unsigned int m68k_lockup_r_16(unsigned int address); 14 | 15 | #endif /* _MEM68K_H_ */ 16 | -------------------------------------------------------------------------------- /gp2/emu/membnk.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _MEMBNK_H_ 3 | #define _MEMBNK_H_ 4 | 5 | /* Function prototypes */ 6 | void z80_write_banked_memory(unsigned int address, unsigned int data); 7 | int z80_read_banked_memory(unsigned int address); 8 | 9 | void z80bank_vdp_w(int address, int data); 10 | int z80bank_vdp_r(int address); 11 | 12 | void z80bank_unused_w(int address, int data); 13 | int z80bank_unused_r(int address); 14 | void z80bank_lockup_w(int address, int data); 15 | int z80bank_lockup_r(int address); 16 | 17 | #endif /* _MEMBNK_H_ */ 18 | -------------------------------------------------------------------------------- /gp2/emu/memvdp.c: -------------------------------------------------------------------------------- 1 | /* 2 | memvdp.c -- 3 | Memory handlers for when the VDP reads the V-bus during DMA. 4 | */ 5 | 6 | #include "shared.h" 7 | 8 | unsigned int vdp_dma_r(unsigned int address) 9 | { 10 | switch((address >> 21) & 7) 11 | { 12 | case 0: /* Cartridge ROM */ 13 | case 1: 14 | return READ_WORD(cart_rom, address); 15 | 16 | case 2: /* Unused */ 17 | case 3: 18 | return 0xFF00; 19 | 20 | case 4: /* Work RAM */ 21 | case 6: 22 | case 7: 23 | return READ_WORD(work_ram, address & 0xFFFF); 24 | 25 | case 5: /* Z80 area and I/O chip */ 26 | 27 | /* Z80 area always returns $FFFF */ 28 | if(address <= 0xA0FFFF) 29 | { 30 | /* Return $FFFF only when the Z80 isn't hogging the Z-bus. 31 | (e.g. Z80 isn't reset and 68000 has the bus) */ 32 | return (zbusack == 0) 33 | ? 0xFFFF 34 | : READ_WORD(work_ram, address & 0xFFFF); 35 | } 36 | else 37 | 38 | /* The I/O chip and work RAM try to drive the data bus which 39 | results in both values being combined in random ways when read. 40 | We return the I/O chip values which seem to have precedence, */ 41 | if(address <= 0xA1001F) 42 | { 43 | int temp = io_read((address >> 1) & 0x0f); 44 | //uint8 temp = gen_io_r((address >> 1) & 0x0F); 45 | return (temp << 8 | temp); 46 | } 47 | else 48 | 49 | /* All remaining locations access work RAM */ 50 | return READ_WORD(work_ram, address & 0xFFFF); 51 | } 52 | 53 | return -1; 54 | } 55 | 56 | -------------------------------------------------------------------------------- /gp2/emu/memvdp.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _MEMVDP_H_ 3 | #define _MEMVDP_H_ 4 | 5 | /* Function prototypes */ 6 | unsigned int vdp_dma_r(unsigned int address); 7 | 8 | #endif /* _MEMVDP_H_ */ 9 | -------------------------------------------------------------------------------- /gp2/emu/memz80.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _MEMZ80_H_ 3 | #define _MEMZ80_H_ 4 | 5 | /* Function prototypes */ 6 | unsigned int cpu_readmem16(unsigned int address); 7 | void cpu_writemem16(unsigned int address, unsigned int data); 8 | unsigned int cpu_readport16(unsigned int port); 9 | void cpu_writeport16(unsigned int port, unsigned int data); 10 | void z80_unused_w(int address, int data); 11 | int z80_unused_r(int address); 12 | void z80_lockup_w(int address, int data); 13 | int z80_lockup_r(int address); 14 | int z80_vdp_r(int address); 15 | void z80_vdp_w(int address, int data); 16 | 17 | #endif /* _MEMZ80_H_ */ 18 | -------------------------------------------------------------------------------- /gp2/emu/porting.txt: -------------------------------------------------------------------------------- 1 | 2 | Introduction 3 | 4 | Genesis Plus has reasonable speed, and very fast rendering. Here are some 5 | details about porting it to another platform 6 | 7 | Requirements 8 | 9 | - At this time the 16-bit rendering code has been well tested and should 10 | be used. There is code to support 8 through 32-bit displays, but I 11 | haven't checked if it still works. 12 | 13 | - Audio output, if enabled, uses stereo 16-bit samples. 14 | 15 | Functions to use: 16 | 17 | int load_rom(char *filename); 18 | 19 | Loads a game which can be in BIN, SMD or ZIP formats. It returns zero if 20 | an error has occured. 21 | 22 | void system_init(void); 23 | 24 | Initializes the virtual Genesis console. Call this once during startup. 25 | 26 | void audio_init(int rate); 27 | 28 | Initialize the sound emulation part of the emulator. Pass zero or don't 29 | call the function to disable sound. Call this after running system_init(). 30 | 31 | void system_reset(void); 32 | 33 | Resets the virtual Genesis console. Call this once during setup, and later 34 | as needed. 35 | 36 | int system_frame(int skip); 37 | 38 | Updates the emulation for a frame. Pass 1 to prevent rendering (which can 39 | be used for frame skipping) and 0 to render the current display. 40 | 41 | This function returns 0 if the virtual Genesis console has locked up. 42 | You can do what you'd like with this information, such as notify the user, 43 | reset the machine, etc. 44 | 45 | If audio is enabled, the snd.buffer[] array will hold the current audio 46 | data for this frame. 47 | 48 | void system_shutdown(void); 49 | 50 | Shuts down the emulator. 51 | 52 | Variables: 53 | 54 | The 'bitmap' structure needs to be filled out prior to calling system_init(). 55 | This provides the rendering code with information about the type of bitmap 56 | it is rendering to. I would advise sticking with a 1024x512 16-bit bitmap: 57 | 58 | memset(&bitmap, 0, sizeof(t_bitmap)); 59 | bitmap.width = 1024; 60 | bitmap.height = 512; 61 | bitmap.depth = 16; 62 | bitmap.granularity = 2; /* Bytes per pixel */ 63 | bitmap.pitch = (bitmap.width * bitmap.granularity); 64 | bitmap.data = (unsigned char *)bmp->pixels; /* Pointer to your bitmap */ 65 | bitmap.viewport.w = 256; /* Initial size of display on power-up (do not change) */ 66 | bitmap.viewport.h = 224; 67 | bitmap.viewport.x = 0x20; /* Offset used for rendering (do not change) */ 68 | bitmap.viewport.y = 0x00; 69 | bitmap.remap = 1; 70 | 71 | The variable 'input.pad[0]' holds the button states for the first player 72 | gamepad. Update this prior to calling system_frame(), and use the bitmasks 73 | defined in system.h such as 'INPUT_UP', etc. 74 | 75 | See the Windows/SDL and DOS drivers for examples. 76 | -------------------------------------------------------------------------------- /gp2/emu/readme.txt: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | Genesis Plus 3 | ---------------------------------------------------------------------------- 4 | 5 | Version 1.2 6 | by Charles Mac Donald 7 | WWW: http://cgfm2.emuviews.com 8 | 9 | What's New 10 | ---------- 11 | 12 | [05/13/03] 13 | - Initial release 14 | 15 | Usage 16 | ----- 17 | 18 | The Windows version runs windowed in a 16-bit desktop with NO sound or 19 | joystick support. 20 | 21 | The DOS version has most of the functionality from SMS Plus, such 22 | as audio, joysticks, etc. 23 | 24 | Windows/DOS controls: 25 | 26 | Arrow Keys - Directional pad 27 | A,S,D,F - 1P gamepad, buttons A, B, C, Start 28 | Tab - Reset 29 | Esc - Exit program 30 | 31 | DOS only: 32 | 33 | End - Exit program 34 | F1-F4 - Set frameskip level (F1 = no skip ... F4 = skip 3 frames) 35 | F8 - Make PCX screen snapshot 36 | F9 - Toggle VSync 37 | F10 - Toggle speed throttling 38 | F11 - Toggle FPS meter 39 | 40 | DOS details: 41 | 42 | You can only support a second player if you are using a joystick driver 43 | that supports more than one joystick. (e.g. Sidewinder, dual pads, etc.) 44 | 45 | Type 'gen -help' on the command line for a list of useful options. 46 | 47 | -res set the display resolution. 48 | -vdriver specify video driver. 49 | -depth specify color depth. (8, 16) 50 | -scanlines use scanlines effect. 51 | -scale scale display to full resolution. (slow) 52 | -vsync wait for vertical sync before blitting. 53 | -sound enable sound. (force speed throttling) 54 | -sndrate specify sound rate. (8000, 11025, 22050, 44100) 55 | -sndcard specify sound card. (0-7) 56 | -swap swap left and right stereo output. 57 | -joy specify joystick type. 58 | 59 | Here is a list of all the video drivers you can pass as a parameter 60 | to the '-vdriver' option: 61 | 62 | auto, safe, vga, modex, vesa2l, vesa3, vbeaf 63 | 64 | Here is a list of all the joystick drivers you can pass as a parameter 65 | to the '-joy' option: 66 | 67 | auto, none, standard, 2pads, 4button, 6button, 8button, fspro, wingex, 68 | sidewinder, gamepadpro, grip, grip4, sneslpt1, sneslpt2, sneslpt3, 69 | psxlpt1, psxlpt2, psxlpt3, n64lpt1, n64lpt2, n64lpt3, db9lpt1, db9lpt2, 70 | db9lpt3, tglpt1, tglpt2, tglpt3, wingwar, segaisa, segapci, segapci2 71 | 72 | You can put any commandline option into a plain text file which should 73 | be called "gen.cfg". Put one option per line, please. Command line options 74 | will override anything in the configuration file. 75 | 76 | Currently the zip loading code can manage a zipfile where the game 77 | image is the first thing in it. If you try to open a huge archive of 78 | games, only the first will be played. 79 | 80 | Credits and Acknowlegements 81 | --------------------------- 82 | 83 | I would like to thank Omar Cornut, Christian Schiller, and Chris MacDonald 84 | for their invaluable help and support with this project. 85 | 86 | Richard Bannister for the Macintosh port and all of the code fixes and 87 | suggestions that have made Genesis Plus a better program. 88 | (http://www.bannister.org) 89 | 90 | The Genesis emulator authors: Bart Trzynadlowski, Quintesson, Steve Snake, 91 | James Ponder, Stef, Gerrie, Sardu. 92 | 93 | The regular people and many lurkers at segadev. 94 | 95 | The MAME team for the CPU and sound chip emulators. 96 | 97 | Everyone who has contributed, donated, and submitted information to help 98 | out Genesis Plus and my efforts documenting the Genesis hardware. 99 | 100 | Contact 101 | ------- 102 | 103 | Charles MacDonald 104 | E-mail: cgfm2@hotmail.com 105 | WWW: http://cgfm2.emuviews.com 106 | 107 | Legal 108 | ----- 109 | 110 | Copyright (C) 1999, 2000, 2001, 2002, 2003 Charles MacDonald 111 | 112 | The source code is distributed under the terms of the GNU General Public 113 | License. 114 | 115 | The Z80 CPU emulator, 68K CPU emulator, and the PSG, YM2612 emulation code 116 | are taken from the MAME project, and terms of their use are covered under 117 | the MAME license. 118 | (http://www.mame.net) 119 | 120 | -------------------------------------------------------------------------------- /gp2/emu/render.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _RENDER_H_ 3 | #define _RENDER_H_ 4 | 5 | 6 | /* Look-up pixel table information */ 7 | #define LUT_MAX (5) 8 | #define LUT_SIZE (0x10000) 9 | 10 | /* Clip structure */ 11 | typedef struct 12 | { 13 | uint8 left; 14 | uint8 right; 15 | uint8 enable; 16 | }clip_t; 17 | 18 | /* Function prototypes */ 19 | int render_init(void); 20 | void render_reset(void); 21 | void render_shutdown(void); 22 | void render_line(int line); 23 | void render_obj(int line, uint8 *buf, uint8 *table); 24 | void render_obj_im2(int line, uint8 *buf, uint8 *table); 25 | void render_ntw(int line, uint8 *buf); 26 | void render_ntw_im2(int line, uint8 *buf); 27 | void render_ntx(int which, int line, uint8 *buf); 28 | void render_ntx_im2(int which, int line, uint8 *buf); 29 | void render_ntx_vs(int which, int line, uint8 *buf); 30 | void update_bg_pattern_cache(void); 31 | void get_hscroll(int line, uint16 *scrolla, uint16 *scrollb); 32 | void window_clip(int line); 33 | int make_lut_bg(int bx, int ax); 34 | int make_lut_obj(int bx, int sx); 35 | int make_lut_bg_ste(int bx, int ax); 36 | int make_lut_obj_ste(int bx, int sx); 37 | int make_lut_bgobj_ste(int bx, int sx); 38 | void remap_8(uint8 *src, uint8 *dst, uint8 *table, int length); 39 | void remap_16(uint8 *src, uint16 *dst, uint16 *table, int length); 40 | void remap_32(uint8 *src, uint32 *dst, uint32 *table, int length); 41 | void merge(uint8 *srca, uint8 *srcb, uint8 *dst, uint8 *table, int width); 42 | void color_update_8(int index, uint16 data); 43 | void color_update_15(int index, uint16 data); 44 | void color_update_16(int index, uint16 data); 45 | void color_update_32(int index, uint16 data); 46 | void make_name_lut(void); 47 | void parse_satb(int line); 48 | 49 | #endif /* _RENDER_H_ */ 50 | 51 | -------------------------------------------------------------------------------- /gp2/emu/shared.h: -------------------------------------------------------------------------------- 1 | #ifndef _SHARED_H_ 2 | #define _SHARED_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include "mdSDK.h" 8 | 9 | #include "types.h" 10 | #include "macros.h" 11 | #include "m68k.h" 12 | #include "z80.h" 13 | #include "genesis.h" 14 | #include "vdp.h" 15 | #include "render.h" 16 | #include "mem68k.h" 17 | #include "memz80.h" 18 | #include "membnk.h" 19 | #include "memvdp.h" 20 | #include "system.h" 21 | 22 | #include "fileio.h" 23 | #include "loadrom.h" 24 | 25 | 26 | //#include "io.h" 27 | #include "gen_io.h" 28 | #include "gen_input.h" 29 | 30 | #include "sound.h" 31 | #include "fm.h" 32 | #include "sn76496.h" 33 | #include "osd.h" 34 | 35 | #endif /* _SHARED_H_ */ 36 | 37 | -------------------------------------------------------------------------------- /gp2/emu/sound/sn76496.h: -------------------------------------------------------------------------------- 1 | #ifndef SN76496_H 2 | #define SN76496_H 3 | 4 | #define MAX_76496 1 5 | 6 | struct SN76496interface 7 | { 8 | int num; 9 | int baseclock[MAX_76496]; 10 | int volume[MAX_76496]; 11 | }; 12 | 13 | /* Function prototypes */ 14 | void SN76496Write(int chip,int data); 15 | void SN76496Update(int chip,signed short int *buffer,int length); 16 | void SN76496_set_clock(int chip,int clock); 17 | void SN76496_set_gain(int chip,int gain); 18 | int SN76496_init(int chip,int clock,int volume,int sample_rate); 19 | int SN76496_sh_start(int clock, int volume, int rate); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /gp2/emu/sound/sound.c: -------------------------------------------------------------------------------- 1 | /* 2 | sound.c 3 | YM2612 and SN76489 emulation 4 | */ 5 | 6 | #include "shared.h" 7 | 8 | /* YM2612 data */ 9 | int fm_timera_tab[0x400]; /* Precalculated timer A values */ 10 | int fm_timerb_tab[0x100]; /* Precalculated timer B values */ 11 | uint8 fm_reg[2][0x100]; /* Register arrays (2x256) */ 12 | uint8 fm_latch[2]; /* Register latches */ 13 | uint8 fm_status; /* Read-only status flags */ 14 | t_timer timer[2]; /* Timers A and B */ 15 | 16 | /* Initialize the YM2612 and SN76489 emulation */ 17 | void sound_init(void) 18 | { 19 | /* Timers run at half the YM2612 input clock */ 20 | float clock = ((53.693175 / 7) / 2); 21 | int i; 22 | 23 | /* Make Timer A table */ 24 | for(i = 0; i < 1024; i += 1) 25 | { 26 | /* Formula is "time(us) = 72 * (1024 - A) / clock" */ 27 | fm_timera_tab[i] = ((int)(float)(72 * (1024 - i)) / (clock)); 28 | } 29 | 30 | /* Make Timer B table */ 31 | for(i = 0; i < 256; i += 1) 32 | { 33 | /* Formula is "time(us) = 1152 * (256 - B) / clock" */ 34 | fm_timerb_tab[i] = (int)(float)(1152 * (256 - i)) / clock; 35 | } 36 | } 37 | 38 | void sound_reset(void) 39 | { 40 | if(snd.enabled) 41 | { 42 | YM2612ResetChip(0); 43 | } 44 | } 45 | 46 | void fm_write(int address, int data) 47 | { 48 | int a0 = (address & 1); 49 | int a1 = (address >> 1) & 1; 50 | 51 | if(a0) 52 | { 53 | /* Register data */ 54 | fm_reg[a1][fm_latch[a1]] = data; 55 | 56 | /* Timer control only in set A */ 57 | if(a1 == 0) 58 | switch(fm_latch[a1]) 59 | { 60 | case 0x24: /* Timer A (LSB) */ 61 | timer[0].index = (timer[0].index & 0x0003) | (data << 2); 62 | timer[0].index &= 0x03FF; 63 | timer[0].base = fm_timera_tab[timer[0].index]; 64 | break; 65 | 66 | case 0x25: /* Timer A (MSB) */ 67 | timer[0].index = (timer[0].index & 0x03FC) | (data & 3); 68 | timer[0].index &= 0x03FF; 69 | timer[0].base = fm_timera_tab[timer[0].index]; 70 | break; 71 | 72 | case 0x26: /* Timer B */ 73 | timer[1].index = data; 74 | timer[1].base = timer[1].count = fm_timerb_tab[timer[1].index]; 75 | break; 76 | 77 | case 0x27: /* Timer Control */ 78 | 79 | /* LOAD */ 80 | timer[0].running = (data >> 0) & 1; 81 | if(timer[0].running) timer[0].count = 0; 82 | timer[1].running = (data >> 1) & 1; 83 | if(timer[1].running) timer[1].count = 0; 84 | 85 | /* ENABLE */ 86 | timer[0].enable = (data >> 2) & 1; 87 | timer[1].enable = (data >> 3) & 1; 88 | 89 | /* RESET */ 90 | if(data & 0x10) fm_status &= ~1; 91 | if(data & 0x20) fm_status &= ~2; 92 | break; 93 | } 94 | } 95 | else 96 | { 97 | /* Register latch */ 98 | fm_latch[a1] = data; 99 | } 100 | 101 | if(snd.enabled) 102 | { 103 | if(snd.fm.curStage - snd.fm.lastStage > 1) 104 | { 105 | int16 *tempBuffer[2]; 106 | tempBuffer[0] = snd.fm.buffer[0] + snd.fm.lastStage; 107 | tempBuffer[1] = snd.fm.buffer[1] + snd.fm.lastStage; 108 | YM2612UpdateOne(0, (int16 **)tempBuffer, snd.fm.curStage - snd.fm.lastStage); 109 | snd.fm.lastStage = snd.fm.curStage; 110 | } 111 | 112 | YM2612Write(0, address & 3, data); 113 | } 114 | } 115 | 116 | 117 | int fm_read(int address) 118 | { 119 | return (fm_status); 120 | } 121 | 122 | 123 | void fm_update_timers(void) 124 | { 125 | int i; 126 | 127 | /* Process YM2612 timers */ 128 | for(i = 0; i < 2; i += 1) 129 | { 130 | /* Is the timer running? */ 131 | if(timer[i].running) 132 | { 133 | /* Each scanline takes up roughly 64 microseconds */ 134 | timer[i].count += 64; 135 | 136 | /* Check if the counter overflowed */ 137 | if(timer[i].count > timer[i].base) 138 | { 139 | /* Reload counter */ 140 | timer[i].count = 0; 141 | 142 | /* Disable timer */ 143 | timer[i].running = 0; 144 | 145 | /* Set overflow flag (if flag setting is enabled) */ 146 | if(timer[i].enable) 147 | { 148 | fm_status |= (1 << i); 149 | } 150 | } 151 | } 152 | } 153 | } 154 | 155 | void psg_write(int data) 156 | { 157 | if(snd.enabled) 158 | { 159 | if(snd.psg.curStage - snd.psg.lastStage > 1) 160 | { 161 | int16 *tempBuffer; 162 | tempBuffer = snd.psg.buffer + snd.psg.lastStage; 163 | SN76496Update(0, tempBuffer, snd.psg.curStage - snd.psg.lastStage); 164 | snd.psg.lastStage = snd.psg.curStage; 165 | } 166 | 167 | SN76496Write(0, data); 168 | } 169 | } 170 | 171 | -------------------------------------------------------------------------------- /gp2/emu/sound/sound.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _SOUND_H_ 3 | #define _SOUND_H_ 4 | 5 | typedef struct 6 | { 7 | int running; 8 | int enable; 9 | int count; 10 | int base; 11 | int index; 12 | } t_timer; 13 | 14 | /* Global variables */ 15 | extern int fm_timera_tab[1024]; 16 | extern int fm_timerb_tab[256]; 17 | extern uint8 fm_reg[2][0x100]; 18 | extern uint8 fm_latch[2]; 19 | extern int timer_status; 20 | extern t_timer timer[2]; 21 | 22 | /* Function prototypes */ 23 | void sound_init(void); 24 | void sound_reset(void); 25 | void fm_write(int address, int data); 26 | int fm_read(int address); 27 | void fm_update_timers(void); 28 | void psg_write(int data); 29 | 30 | #endif /* _SOUND_H_ */ 31 | -------------------------------------------------------------------------------- /gp2/emu/system.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pascalorama/megadrive-studio/8289e8ce63f6c4584f57ec6afc27f0361809ba0e/gp2/emu/system.c -------------------------------------------------------------------------------- /gp2/emu/system.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _SYSTEM_H_ 3 | #define _SYSTEM_H_ 4 | 5 | /* Input devices */ 6 | //#define MAX_DEVICES (8) /* Unsure of maximum */ 7 | //#define DEVICE_2BUTTON (0) /* 2-button gamepad */ 8 | //#define DEVICE_3BUTTON (1) /* 3-button gamepad */ 9 | //#define DEVICE_6BUTTON (2) /* 6-button gamepad */ 10 | 11 | /* Input bitmasks */ 12 | //#define INPUT_MODE (0x00000800) 13 | //#define INPUT_Z (0x00000400) 14 | //#define INPUT_Y (0x00000200) 15 | //#define INPUT_X (0x00000100) 16 | //#define INPUT_START (0x00000080) 17 | //#define INPUT_C (0x00000040) 18 | //#define INPUT_B (0x00000020) 19 | //#define INPUT_A (0x00000010) 20 | //#define INPUT_LEFT (0x00000008) 21 | //#define INPUT_RIGHT (0x00000004) 22 | //#define INPUT_DOWN (0x00000002) 23 | //#define INPUT_UP (0x00000001) 24 | 25 | extern uint32 count_m68k; 26 | 27 | typedef struct 28 | { 29 | uint8 *data; /* Bitmap data */ 30 | int width; /* Bitmap width (32+512+32) */ 31 | int height; /* Bitmap height (256) */ 32 | int depth; /* Color depth (8 bits) */ 33 | int pitch; /* Width of bitmap in bytes */ 34 | int granularity; /* Size of each pixel in bytes */ 35 | int remap; /* 1= Translate pixel data */ 36 | struct { 37 | int x; /* X offset of viewport within bitmap */ 38 | int y; /* Y offset of viewport within bitmap */ 39 | int w; /* Width of viewport */ 40 | int h; /* Height of viewport */ 41 | int ow; /* Previous width of viewport */ 42 | int oh; /* Previous height of viewport */ 43 | int changed; /* 1= Viewport width or height have changed */ 44 | }viewport; 45 | }t_bitmap; 46 | 47 | //typedef struct 48 | //{ 49 | // uint8 dev[MAX_DEVICES]; /* Can be any of the DEVICE_* values */ 50 | // uint32 pad[MAX_DEVICES]; /* Can be any of the INPUT_* bitmasks */ 51 | // uint32 system; /* Can be any of the SYSTEM_* bitmasks */ 52 | //}t_input; 53 | 54 | typedef struct 55 | { 56 | int sample_rate; /* Sample rate (8000-44100) */ 57 | int enabled; /* 1= sound emulation is enabled */ 58 | int buffer_size; /* Size of sound buffer (in bytes) */ 59 | int16 *buffer[2]; /* Signed 16-bit stereo sound data */ 60 | struct { 61 | int curStage; 62 | int lastStage; 63 | int16 *buffer[2]; 64 | } fm; 65 | struct { 66 | int curStage; 67 | int lastStage; 68 | int16 *buffer; 69 | } psg; 70 | }t_snd; 71 | 72 | /* Global variables */ 73 | extern t_bitmap bitmap; 74 | //extern t_input input; 75 | extern t_snd snd; 76 | 77 | /* Function prototypes */ 78 | void system_init(void); 79 | int system_frame(int skip,int tick); 80 | int system_stepcpu(int do_skip,int tick); 81 | void system_reset(void); 82 | void system_shutdown(void); 83 | int audio_init(int rate); 84 | void audio_update(void); 85 | 86 | #endif /* _SYSTEM_H_ */ 87 | 88 | -------------------------------------------------------------------------------- /gp2/emu/todo.txt: -------------------------------------------------------------------------------- 1 | 2 | Here are some technical details about things that need to be fixed or 3 | added to Genesis Plus. 4 | 5 | Missing features: 6 | 7 | - Support for 6-button controllers 8 | - SRAM management 9 | - Game Genie / PAR patch codes 10 | 11 | The VDP code could use a lot of cleaning up. 12 | 13 | The rendering code is missing a few bits: 14 | 15 | - Sprite collision 16 | - Window bug 17 | 18 | I think the "C" 68000 emulator either has some bugs or I'm not using it 19 | correctly. Older DOS-only versions used Turbo68K, which had ran games 20 | much better, especially with regards to interrupt handling. 21 | 22 | Things that need to be fixed: 23 | 24 | - Raster garbage on third road in Thunder Blade. 25 | 26 | - Added country codes for Dragon Slayer, but game locks up after 27 | passing country check. 28 | 29 | - No inputs in Samurai Shodown. 30 | (This game doesn't initialize the port direction registers, at least not 31 | directly. Emulation bug or problem with the game?) 32 | 33 | - Palette and raster problems in Mortal Kombat. 34 | 35 | - Bad raster effects and VRAM corruption in Super Skidmarks. 36 | (Needs PAL timing) 37 | 38 | - Palette problems in Sonic 2 title screen. 39 | 40 | - Masked half of Sonic sprite visible on Sonic title screen. 41 | 42 | - Sprite masking doesn't work in Micro Machines subscreen. 43 | 44 | - Music has slow tempo in Batman & Robin. (doesn't seem to be a problem 45 | with the YM2612 timers - Wonderboy 3 is normal) 46 | 47 | - Music has jerky playback in Sonic 2, 3, 3D Blast. If you run the Z80 48 | emulation for one scanline after requesting an interrupt, it runs fine. 49 | 50 | - DAC and PSG output are too loud, both are divided by two for now 51 | (though the PSG should be a bit quieter and the DAC a bit louder) 52 | 53 | - Undead Line locks after selecting a stage, also the Z80 sound halts 54 | after the first note is played. 55 | 56 | This game single steps the Z80 with the following code: 57 | 58 | MOVEM.L D0,-(A7) ; 009C7C 48 E7 80 00 59 | ORI #$0200,SR ; 009C80 00 7C 02 00 60 | ; Get control of the Z-bus 61 | MOVE.W #$0100,$00A11100 ; 009C84 33 FC 01 00 00 A1 11 00 62 | BTST #$00,$00A11100 ; 009C8C 08 39 00 00 00 A1 11 00 63 | BNE.S *-$08 [00009C8C] ; 009C94 66 F6 64 | ; Check driver status byte. If zero, release bus and exit. 65 | TST.B $00A00008 ; 009C96 4A 39 00 A0 00 08 66 | BEQ *+$0016 [00009CB2] ; 009C9C 67 00 00 14 67 | ; Release bus and wait for Z80 to resume control. Then restart the loop 68 | ; and immediately get the bus back again, assuming the Z80 ran at least 69 | ; one instruction in the meantime. 70 | CLR.W $00A11100 ; 009CA0 42 79 00 A1 11 00 71 | BTST #$00,$00A11100 ; 009CA6 08 39 00 00 00 A1 11 00 72 | BEQ.S *-$08 [00009CA6] ; 009CAE 67 F6 73 | BRA.S *-$2C [00009C84] ; 009CB0 60 D2 74 | ; Release bus and exit. 75 | CLR.W $00A11100 ; 009CB2 42 79 00 A1 11 00 76 | ANDI #$FDFF,SR ; 009CB8 02 7C FD FF 77 | MOVEM.L (A7)+,D0 ; 009CBC 4C DF 00 01 78 | RTS ; 009CC0 4E 75 79 | 80 | -------------------------------------------------------------------------------- /gp2/emu/types.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _TYPES_H_ 3 | #define _TYPES_H_ 4 | 5 | typedef unsigned char uint8; 6 | typedef unsigned short int uint16; 7 | typedef unsigned long int uint32; 8 | 9 | typedef signed char int8; 10 | typedef signed short int int16; 11 | typedef signed long int int32; 12 | 13 | #endif /* _TYPES_H_ */ 14 | 15 | -------------------------------------------------------------------------------- /gp2/emu/vcnt.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _VCNT_H_ 3 | #define _VCNT_H_ 4 | 5 | static const char vc28[262] = 6 | { 7 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 8 | 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 9 | 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 10 | 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 11 | 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 12 | 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 13 | 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 14 | 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 15 | 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 16 | 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 17 | 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 18 | 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 19 | 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 20 | 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 21 | 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 22 | 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 23 | 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF 24 | }; 25 | 26 | #endif /* _VCNT_H_ */ 27 | -------------------------------------------------------------------------------- /gp2/emu/vdp.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _VDP_H_ 3 | #define _VDP_H_ 4 | 5 | extern uint16 irq_status; 6 | 7 | 8 | 9 | /* Global variables */ 10 | extern uint8 sat[0x400]; 11 | extern uint8 vram[0x10000]; 12 | extern uint8 cram[0x80]; 13 | extern uint8 vsram[0x80]; 14 | extern uint8 reg[0x20]; 15 | extern uint16 status; 16 | extern uint16 ntab; 17 | extern uint16 ntbb; 18 | extern uint16 ntwb; 19 | extern uint16 satb; 20 | extern uint16 hscb; 21 | extern uint8 is_color_dirty; 22 | extern uint8 color_dirty[0x40]; 23 | extern uint8 border; 24 | extern uint8 is_border_dirty; 25 | extern uint8 bg_name_dirty[0x800]; 26 | extern uint16 bg_name_list[0x800]; 27 | extern uint16 bg_list_index; 28 | extern uint8 bg_pattern_cache[0x80000]; 29 | extern uint8 playfield_shift; 30 | extern uint8 playfield_col_mask; 31 | extern uint16 playfield_row_mask; 32 | extern uint32 y_mask; 33 | extern int vint_pending; 34 | extern int hint_pending; 35 | extern int scanline; 36 | extern int counter; 37 | extern int im2_flag; 38 | extern int frame_end; 39 | extern int v_counter, v_update; 40 | extern uint16 hc_latch; 41 | 42 | extern void (*color_update)(int index, uint16 data); 43 | 44 | /* Function prototypes */ 45 | void vdp_init(void); 46 | void vdp_reset(void); 47 | void vdp_shutdown(void); 48 | void vdp_ctrl_w(uint16 data); 49 | uint16 vdp_ctrl_r(void); 50 | void vdp_data_w(uint16 data); 51 | uint16 vdp_data_r(void); 52 | void vdp_reg_w(uint8 r, uint8 d); 53 | uint16 vdp_hvc_r(void); 54 | void dma_copy(void); 55 | void dma_vbus(void); 56 | void vdp_test_w(uint16 value); 57 | 58 | #endif /* _VDP_H_ */ 59 | -------------------------------------------------------------------------------- /gp2/emu/win/error.c: -------------------------------------------------------------------------------- 1 | /* 2 | error.c -- 3 | Error logging 4 | */ 5 | 6 | #include "shared.h" 7 | 8 | FILE *error_log; 9 | extern t_Callbacks *m_CallBacks; 10 | 11 | struct { 12 | int enabled; 13 | int verbose; 14 | FILE *log; 15 | } t_error; 16 | 17 | void error_init(void) 18 | { 19 | #ifdef DEBUG 20 | //error_log = fopen("error.log","w"); 21 | #endif 22 | } 23 | 24 | void error_shutdown(void) 25 | { 26 | #ifdef DEBUG 27 | //if(error_log) fclose(error_log); 28 | #endif 29 | } 30 | 31 | void error(char *format, ...) 32 | { 33 | va_list ap; 34 | char token[0x100]; 35 | char msg[0x100]; 36 | 37 | strcpy(msg, "\0"); 38 | va_start(ap, format); 39 | vsprintf(token, format, ap); 40 | strcat(msg, token); 41 | va_end(ap); 42 | 43 | m_CallBacks->m_fctLogMessage(0,msg); 44 | } 45 | 46 | void level_error(int level,char *format, ...) 47 | { 48 | va_list ap; 49 | char token[0x100]; 50 | char msg[0x100]; 51 | 52 | strcpy(msg, "\0"); 53 | va_start(ap, format); 54 | vsprintf(token, format, ap); 55 | strcat(msg, token); 56 | va_end(ap); 57 | 58 | m_CallBacks->m_fctLogMessage(level,msg); 59 | } 60 | 61 | -------------------------------------------------------------------------------- /gp2/emu/win/error.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _ERROR_H_ 3 | #define _ERROR_H_ 4 | 5 | /* Global variables */ 6 | FILE *error_log; 7 | 8 | /* Function prototypes */ 9 | void error_init(void); 10 | void error_shutdown(void); 11 | void error(char *format, ...); 12 | 13 | #endif /* _ERROR_H_ */ 14 | -------------------------------------------------------------------------------- /gp2/emu/win/main.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "shared.h" 5 | 6 | int timer_count = 0; 7 | int old_timer_count = 0; 8 | int paused = 0; 9 | int frame_count = 0; 10 | 11 | int update_input(void); 12 | unsigned char *keystate; 13 | 14 | 15 | Uint32 fps_callback(Uint32 interval) 16 | { 17 | if(paused) return 1000/60; 18 | timer_count++; 19 | if(timer_count % 60 == 0) 20 | { 21 | int fps = frame_count; 22 | char caption[32]; 23 | sprintf(caption, "Genesis Plus/SDL FPS=%d", fps); 24 | SDL_WM_SetCaption(caption, NULL); 25 | frame_count = 0; 26 | } 27 | return 1000/60; 28 | } 29 | 30 | 31 | int main (int argc, char **argv) 32 | { 33 | int running = 1; 34 | 35 | SDL_Rect viewport, src; 36 | SDL_Surface *bmp, *screen; 37 | SDL_Event event; 38 | 39 | error_init(); 40 | 41 | /* Print help if no game specified */ 42 | if(argc < 2) 43 | { 44 | char caption[256]; 45 | sprintf(caption, "Genesis Plus\nby Charles MacDonald\nWWW: http://cgfm2.emuviews.com\nusage: %s gamename\n", argv[0]); 46 | MessageBox(NULL, caption, "Information", 0); 47 | exit(1); 48 | } 49 | 50 | /* Load game */ 51 | if(!load_rom(argv[1])) 52 | { 53 | char caption[256]; 54 | sprintf(caption, "Error loading file `%s'.", argv[1]); 55 | MessageBox(NULL, caption, "Error", 0); 56 | exit(1); 57 | } 58 | 59 | viewport.x = 0; 60 | viewport.y = 0; 61 | viewport.w = 256; 62 | viewport.h = 224; 63 | 64 | src.x = 32; 65 | src.y = 0; 66 | src.w = viewport.w; 67 | src.h = viewport.h; 68 | 69 | if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) 70 | { 71 | exit(1); 72 | } 73 | SDL_WM_SetCaption("Genesis Plus/SDL", NULL); 74 | 75 | screen = SDL_SetVideoMode(viewport.w, viewport.h, 16, SDL_SWSURFACE); 76 | viewport.x = 0; 77 | viewport.y = 0; 78 | 79 | bmp = SDL_CreateRGBSurface(SDL_SWSURFACE, 1024, 512, 16, 0xF800, 0x07E0, 0x001F, 0x0000); 80 | 81 | 82 | 83 | memset(&bitmap, 0, sizeof(t_bitmap)); 84 | bitmap.width = 1024; 85 | bitmap.height = 512; 86 | bitmap.depth = 16; 87 | bitmap.granularity = 2; 88 | bitmap.pitch = (bitmap.width * bitmap.granularity); 89 | bitmap.data = (unsigned char *)bmp->pixels; 90 | bitmap.viewport.w = 256; 91 | bitmap.viewport.h = 224; 92 | bitmap.viewport.x = 0x20; 93 | bitmap.viewport.y = 0x00; 94 | bitmap.remap = 1; 95 | 96 | system_init(); 97 | system_reset(); 98 | 99 | SDL_SetTimer(1000/60, fps_callback); 100 | 101 | while(running) 102 | { 103 | running = update_input(); 104 | 105 | while (SDL_PollEvent(&event)) 106 | { 107 | switch(event.type) 108 | { 109 | case SDL_QUIT: /* Windows was closed */ 110 | running = 0; 111 | break; 112 | 113 | case SDL_ACTIVEEVENT: /* Window focus changed or was minimized */ 114 | if(event.active.state & (SDL_APPINPUTFOCUS | SDL_APPACTIVE)) 115 | { 116 | paused = !event.active.gain; 117 | } 118 | break; 119 | 120 | default: 121 | break; 122 | } 123 | } 124 | 125 | if(!paused) 126 | { 127 | frame_count++; 128 | 129 | update_input(); 130 | 131 | if(!system_frame(0)) 132 | system_reset(); 133 | 134 | if(bitmap.viewport.changed) 135 | { 136 | bitmap.viewport.changed = 0; 137 | src.w = bitmap.viewport.w; 138 | src.h = bitmap.viewport.h; 139 | viewport.w = bitmap.viewport.w; 140 | viewport.h = bitmap.viewport.h; 141 | screen = SDL_SetVideoMode(bitmap.viewport.w, bitmap.viewport.h, 16, SDL_SWSURFACE); 142 | } 143 | 144 | SDL_BlitSurface(bmp, &src, screen, &viewport); 145 | SDL_UpdateRect(screen, viewport.x, viewport.y, viewport.w, viewport.h); 146 | } 147 | } 148 | 149 | system_shutdown(); 150 | SDL_Quit(); 151 | error_shutdown(); 152 | 153 | return 0; 154 | } 155 | 156 | 157 | /* Check if a key is pressed */ 158 | int check_key(int code) 159 | { 160 | static char lastbuf[0x100] = {0}; 161 | 162 | if((!keystate[code]) && (lastbuf[code] == 1)) 163 | lastbuf[code] = 0; 164 | 165 | if((keystate[code]) && (lastbuf[code] == 0)) 166 | { 167 | lastbuf[code] = 1; 168 | return (1); 169 | } 170 | 171 | return (0); 172 | } 173 | 174 | int update_input(void) 175 | { 176 | int running = 1; 177 | 178 | keystate = SDL_GetKeyState(NULL); 179 | 180 | memset(&input, 0, sizeof(t_input)); 181 | if(keystate[SDLK_UP]) input.pad[0] |= INPUT_UP; 182 | else 183 | if(keystate[SDLK_DOWN]) input.pad[0] |= INPUT_DOWN; 184 | if(keystate[SDLK_LEFT]) input.pad[0] |= INPUT_LEFT; 185 | else 186 | if(keystate[SDLK_RIGHT]) input.pad[0] |= INPUT_RIGHT; 187 | 188 | if(keystate[SDLK_a]) input.pad[0] |= INPUT_A; 189 | if(keystate[SDLK_s]) input.pad[0] |= INPUT_B; 190 | if(keystate[SDLK_d]) input.pad[0] |= INPUT_C; 191 | if(keystate[SDLK_f]) input.pad[0] |= INPUT_START; 192 | if(keystate[SDLK_z]) input.pad[0] |= INPUT_X; 193 | if(keystate[SDLK_x]) input.pad[0] |= INPUT_Y; 194 | if(keystate[SDLK_c]) input.pad[0] |= INPUT_Z; 195 | if(keystate[SDLK_v]) input.pad[0] |= INPUT_MODE; 196 | 197 | if(keystate[SDLK_TAB]) system_reset(); 198 | 199 | if(keystate[SDLK_ESCAPE]) running = 0; 200 | return (running); 201 | } 202 | 203 | 204 | -------------------------------------------------------------------------------- /gp2/emu/win/main.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _MAIN_H_ 3 | #define _MAIN_H_ 4 | 5 | 6 | 7 | #endif /* _MAIN_H_ */ 8 | -------------------------------------------------------------------------------- /gp2/emu/win/osd.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _OSD_H_ 3 | #define _OSD_H_ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | #include "error.h" 15 | #include "shared.h" 16 | #include "main.h" 17 | 18 | #endif /* _OSD_H_ */ 19 | -------------------------------------------------------------------------------- /gp2/emu/zip/zip.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pascalorama/megadrive-studio/8289e8ce63f6c4584f57ec6afc27f0361809ba0e/gp2/emu/zip/zip.zip -------------------------------------------------------------------------------- /gp2/emu/zip/zlib.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pascalorama/megadrive-studio/8289e8ce63f6c4584f57ec6afc27f0361809ba0e/gp2/emu/zip/zlib.lib -------------------------------------------------------------------------------- /gp2/gp2.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "gp2"=.\gp2.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Project: "mdconsole"=..\mdconsole\mdconsole.dsp - Package Owner=<4> 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<4> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | Global: 31 | 32 | Package=<5> 33 | {{{ 34 | }}} 35 | 36 | Package=<3> 37 | {{{ 38 | }}} 39 | 40 | ############################################################################### 41 | 42 | -------------------------------------------------------------------------------- /gp2/main.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pascalorama/megadrive-studio/8289e8ce63f6c4584f57ec6afc27f0361809ba0e/gp2/main.c -------------------------------------------------------------------------------- /mdstudio/CEPI_IHM.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | Your application description here. 10 | 11 | 12 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /mdstudio/DXKeyboard.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // 4 | // 5 | // NOT PORTABLE I'M USING DIB 6 | /////////////////////////////////////////////////////////////////////////////// 7 | // Includes 8 | 9 | #include "include/mdShared.h" 10 | #include "include/DXKeyboard.h" 11 | 12 | /////////////////////////////////////////////////////////////////////////////// 13 | // Constructor 14 | /////////////////////////////////////////////////////////////////////////////// 15 | 16 | DXKeyboard::DXKeyboard(HWND hwnd,HINSTANCE hinst) 17 | { 18 | HRESULT rval=DirectInputCreate(hinst,DIRECTINPUT_VERSION,&lpdi,NULL); 19 | if(rval!=DI_OK) 20 | { DIError(rval);} 21 | 22 | if(lpdi) 23 | { 24 | rval=lpdi->CreateDevice(GUID_SysKeyboard,&lpdi_keyboard,NULL); 25 | if(rval!=DI_OK) 26 | { DIError(rval); 27 | } 28 | 29 | rval=lpdi_keyboard->SetCooperativeLevel(hwnd,DISCL_BACKGROUND | DISCL_NONEXCLUSIVE); 30 | if(rval!=DI_OK) 31 | { DIError(rval); 32 | } 33 | 34 | rval=lpdi_keyboard->SetDataFormat(&c_dfDIKeyboard); 35 | if(rval!=DI_OK) 36 | { DIError(rval); 37 | } 38 | 39 | rval=lpdi_keyboard->Acquire(); 40 | if(rval!=DI_OK) 41 | { DIError(rval); 42 | } 43 | } 44 | } 45 | 46 | DXKeyboard::~DXKeyboard() 47 | { 48 | if(lpdi_keyboard) 49 | { memset(keyboard_state,0,sizeof(keyboard_state)); 50 | lpdi_keyboard->Unacquire(); 51 | if(lpdi_keyboard != NULL) { lpdi_keyboard->Release(); lpdi_keyboard = NULL; } 52 | } 53 | if(lpdi) 54 | lpdi->Release(); 55 | } 56 | 57 | 58 | void DXKeyboard::Update(void) 59 | { 60 | if(lpdi_keyboard) 61 | { HRESULT i_rval=lpdi_keyboard->GetDeviceState(256,keyboard_state); 62 | 63 | if(i_rval!=DI_OK) 64 | { 65 | if(i_rval==DIERR_INPUTLOST || i_rval == DIERR_NOTACQUIRED) 66 | { if(lpdi_keyboard) 67 | lpdi_keyboard->Acquire(); 68 | } 69 | } 70 | } 71 | } 72 | 73 | int DXKeyboard::Check_Key(int keynum) 74 | { int ret=0; 75 | if(lpdi_keyboard) 76 | { if(keyboard_state[keynum] & 0x80) 77 | { ret=1;} 78 | } 79 | return ret; 80 | } 81 | 82 | 83 | void DXKeyboard::DIError(HRESULT rval) 84 | { 85 | wxLogError("Error initializing keyboard"); 86 | //MessageBox(hwnd,"Error initializing input","P-O-R Direct input",MB_OK| MB_ICONEXCLAMATION); 87 | 88 | } -------------------------------------------------------------------------------- /mdstudio/include/DXKeyboard.h: -------------------------------------------------------------------------------- 1 | #ifndef __DXKeyboard_H__ 2 | #define __DXKeyboard_H__ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | // Class definition 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | 9 | #define INITGUID 10 | #define DIRECTINPUT_VERSION 0x0500 11 | #include 12 | 13 | class DXKeyboard 14 | { 15 | /////////////////////////////////////////////////////////////////////////// 16 | public: 17 | /////// 18 | 19 | DXKeyboard(HWND hwnd,HINSTANCE hinst); 20 | ~DXKeyboard(); 21 | 22 | void Update(void); 23 | int Check_Key(int keynum); 24 | 25 | /////////////////////////////////////////////////////////////////////////// 26 | protected: 27 | ////////// 28 | 29 | LPDIRECTINPUT lpdi; 30 | 31 | LPDIRECTINPUTDEVICE lpdi_keyboard; 32 | unsigned char keyboard_state[256]; 33 | 34 | void DIError(HRESULT rval); 35 | 36 | 37 | }; 38 | 39 | /////////////////////////////////////////////////////////////////////////////// 40 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdApp.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // 4 | 5 | #ifndef __MDAPP_H__ 6 | #define __MDAPP_H__ 7 | 8 | /////////////////////////////////////////////////////////////////////////////// 9 | // class definition 10 | /////////////////////////////////////////////////////////////////////////////// 11 | 12 | #include "include/mdPluginList.h" 13 | #include "include/mdProject.h" 14 | 15 | class mdEmu; 16 | class mdDibBitmap; 17 | class mdOutputDataPlugin; 18 | class mdProject; 19 | 20 | class mdApp : public wxApp 21 | { 22 | /////////////////////////////////////////////////////////////////////////// 23 | public: 24 | /////// 25 | virtual bool OnInit(); 26 | virtual int OnExit(); 27 | 28 | bool LoadRom(void); 29 | bool LoadRom(wxChar* filename); 30 | bool ReloadRom(void); 31 | int RunFrame(void); 32 | 33 | mdFrmMain* GetFrmMain(void){ return m_FrmMain;} 34 | 35 | wxString& GetRomFileName(void){ return m_RomFileName;} 36 | mdDibBitmap* GetEmuVideoBuffer(void); 37 | 38 | int OutputPicture(wxString &filename); 39 | wxString& GetAppPath(void){ return m_AppPath;} 40 | 41 | mdProject* GetProject(void); 42 | 43 | int DumpMemoryToFile(wxString& FileName,unsigned char* Data,int base,int length,bool SwapByte=true); 44 | 45 | /////////////////////////////////////////////////////////////////////////// 46 | protected: 47 | ////////// 48 | mdFrmMain *m_FrmMain; 49 | // mdEmu *m_Emu; 50 | wxString m_RomFileName; 51 | wxString m_AppPath; 52 | mdProject m_Project; 53 | 54 | mdPluginsList *m_OutputPlugins; 55 | 56 | 57 | 58 | 59 | /////////////////////////////////////////////////////////////////////////// 60 | private: 61 | //////// 62 | 63 | 64 | }; 65 | 66 | DECLARE_APP(mdApp) 67 | 68 | /////////////////////////////////////////////////////////////////////////////// 69 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdBreakPoint.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdBreakPoint_H__ 2 | #define __mdBreakPoint_H__ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | // Class definition 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | class mdBreakPoint 9 | { 10 | /////////////////////////////////////////////////////////////////////////// 11 | public: 12 | /////// 13 | 14 | mdBreakPoint(); 15 | ~mdBreakPoint(); 16 | 17 | bool m_Enabled; 18 | int m_Hits; 19 | int m_Count; 20 | unsigned char m_Rules; 21 | /////////////////////////////////////////////////////////////////////////// 22 | protected: 23 | ////////// 24 | 25 | }; 26 | 27 | /////////////////////////////////////////////////////////////////////////////// 28 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdCRAMPanel.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdCRAMPanel_H__ 2 | #define __mdCRAMPanel_H__ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | // Class definition 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | class mdEmu; 9 | 10 | class mdCRAMPanel: public wxPanel 11 | { 12 | /////////////////////////////////////////////////////////////////////////// 13 | public: 14 | /////// 15 | 16 | mdCRAMPanel( wxWindow* parent, 17 | wxWindowID id, 18 | const wxPoint& pos, 19 | const wxSize& size, 20 | long style, 21 | const wxString& name); 22 | ~mdCRAMPanel(); 23 | void UpdateCRAM(void); 24 | void SetCRAM(unsigned char* cram); 25 | 26 | /////////////////////////////////////////////////////////////////////////// 27 | protected: 28 | ////////// 29 | 30 | unsigned char *m_CRAM; 31 | 32 | void OnPaint(wxPaintEvent& event); 33 | void OnEraseBackground(wxEraseEvent& event); 34 | 35 | void OnMouseMotion(wxMouseEvent& event); 36 | 37 | DECLARE_EVENT_TABLE() 38 | }; 39 | 40 | /////////////////////////////////////////////////////////////////////////////// 41 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdDefaultPlugin.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdDefaultPlugin_H__ 2 | #define __mdDefaultPlugin_H__ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | // Class definition 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | class wxDynamicLibrary; 9 | 10 | #include "include/mdSDK.h" 11 | 12 | class mdDefaultPlugin 13 | { 14 | /////////////////////////////////////////////////////////////////////////// 15 | public: 16 | /////// 17 | 18 | mdDefaultPlugin(const wxString& filename); 19 | ~mdDefaultPlugin(); 20 | 21 | wxString GetDescription(void); 22 | wxString GetAuthor(void); 23 | wxString GetContactInfo(void); 24 | wxString GetBuildVersion(void); 25 | wxString GetID(void); 26 | wxString GetExt(void); 27 | 28 | /////////////////////////////////////////////////////////////////////////// 29 | protected: 30 | ////////// 31 | 32 | typedef char* (*fctGetDescription)(void); 33 | typedef char* (*fctGetAuthor)(void); 34 | typedef char* (*fctGetContactInfo)(void); 35 | typedef char* (*fctGetBuildVersion)(void); 36 | typedef char* (*fctGetID)(void); 37 | typedef char* (*fctGetExt)(void); 38 | 39 | wxString m_FileName; 40 | wxDynamicLibrary *m_Library; 41 | 42 | void GetSymbols(void); 43 | 44 | fctGetDescription m_fctGetDescription; 45 | fctGetAuthor m_fctGetAuthor; 46 | fctGetContactInfo m_fctGetContactInfo; 47 | fctGetBuildVersion m_fctGetBuildVersion; 48 | fctGetID m_fctGetID; 49 | fctGetExt m_fctGetExt; 50 | 51 | }; 52 | 53 | /////////////////////////////////////////////////////////////////////////////// 54 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdDibBitmap.h: -------------------------------------------------------------------------------- 1 | #ifndef _CDIBBITMAP_H_ 2 | #define _CDIBBITMAP_H_ 3 | 4 | #ifndef _WINDOWS_ 5 | #include "windows.h" 6 | #endif 7 | 8 | /////////////////////////////////////////////////////////////////////////////// 9 | // Class definition 10 | /////////////////////////////////////////////////////////////////////////////// 11 | 12 | class mdDibBitmap 13 | { 14 | /////////////////////////////////////////////////////////////////////////// 15 | public: 16 | /////// 17 | mdDibBitmap(int iWidth,int iHeight,BYTE bDepth); 18 | ~mdDibBitmap(); 19 | 20 | void PutPixel(int x, int y, BYTE r, BYTE g, BYTE b); 21 | void Clear(BYTE r,BYTE g,BYTE b); 22 | 23 | BYTE Depth; 24 | int Width,Height; 25 | BYTE *Data; 26 | LPBITMAPINFO lpBmi; 27 | 28 | }; 29 | 30 | /////////////////////////////////////////////////////////////////////////////// 31 | 32 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdDisAsmPanel.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdDisAsmPanel_H__ 2 | #define __mdDisAsmPanel_H__ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | // Class definition 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | class mdEmu; 9 | 10 | class mdDisAsmPanel: public wxWindow 11 | { 12 | /////////////////////////////////////////////////////////////////////////// 13 | public: 14 | /////// 15 | 16 | mdDisAsmPanel( wxWindow* parent, 17 | wxWindowID id, 18 | const wxPoint& pos, 19 | const wxSize& size, 20 | long style, 21 | const wxString& name); 22 | ~mdDisAsmPanel(); 23 | 24 | void SetEmu(mdEmu* m); 25 | 26 | void DisAsm(); 27 | void OnSize(wxSizeEvent &event); 28 | 29 | unsigned int m_PageTopPC; 30 | unsigned int m_PageBottomPC; 31 | 32 | /////////////////////////////////////////////////////////////////////////// 33 | protected: 34 | ////////// 35 | 36 | int m_RowPosition; 37 | mdEmu *m_Emu; 38 | 39 | wxString m_DisAsmText[256]; 40 | unsigned int m_DisAsmPC[256]; 41 | bool m_IsBreakPoint[256]; 42 | bool m_IsLabel[256]; 43 | 44 | void OnPaint(wxPaintEvent& event); 45 | void OnEraseBackground(wxEraseEvent& event); 46 | void OnLeftDoubleClick(wxMouseEvent &event); 47 | 48 | 49 | DECLARE_EVENT_TABLE() 50 | }; 51 | 52 | /////////////////////////////////////////////////////////////////////////////// 53 | 54 | 55 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdDisasm.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdDisasm_H__ 2 | #define __mdDisasm_H__ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | // Class definition 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | class mdDisasm 9 | { 10 | /////////////////////////////////////////////////////////////////////////// 11 | public: 12 | /////// 13 | mdDisasm(unsigned int pc,char* disasm); 14 | ~mdDisasm(); 15 | 16 | /////////////////////////////////////////////////////////////////////////// 17 | protected: 18 | ////////// 19 | int m_Pc; 20 | 21 | 22 | 23 | /////////////////////////////////////////////////////////////////////////// 24 | private: 25 | //////// 26 | 27 | 28 | }; 29 | 30 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdEmu.h: -------------------------------------------------------------------------------- 1 | #ifndef _mdEmu_H_ 2 | #define _mdEmu_H_ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | // Class definition 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | class mdDibBitmap; 9 | class mdPlugin; 10 | #include "mdSDK.h" 11 | class mdDisasm; 12 | class mdBreakPoint; 13 | class mdSpy; 14 | class mdSpiesList; 15 | class mdVideoSurface; 16 | 17 | class mdEmu 18 | { 19 | /////////////////////////////////////////////////////////////////////////// 20 | public: 21 | /////// 22 | mdEmu(const wxString &plug); 23 | ~mdEmu(); 24 | 25 | int LoadRom(const wxString &rom); 26 | int RunFrame(void); 27 | int StepInto(void); 28 | unsigned int DisAsm(wxString &buf,unsigned int pc); 29 | int ExecuteBreakPoint(unsigned int pc); 30 | bool CheckIsBreakPoint(unsigned int pc); 31 | void CreateBreakPoint(unsigned int pc); 32 | void EraseBreakPoint(unsigned int pc); 33 | void FreeRom(void); 34 | 35 | unsigned int M68K_ReadMemory8(unsigned int addr); 36 | unsigned int M68K_ReadMemory16(unsigned int addr); 37 | unsigned int M68K_ReadMemory32(unsigned int addr); 38 | 39 | unsigned int GetCpuRegister(int cpu_id,int reg_id); 40 | 41 | void SetInput(int player_id,int value); 42 | 43 | unsigned char* VDPRegs(){ return m_VDPRegs;} 44 | 45 | 46 | int GenerateScreenshot(mdPictureInfo *info,unsigned char* pixels,mdColor *pal); 47 | 48 | mdDibBitmap* GetBitmap(void){ return m_Bitmap;} 49 | // mdVideoSurface* GetBitmap(void){ return m_Bitmap;} 50 | 51 | void GetRomInfo(t_RomInfo *i); 52 | 53 | unsigned char* GetCRAM(void); 54 | unsigned char* GetVRAM(void); 55 | unsigned char* GetVSRAM(void); 56 | 57 | unsigned char* GetRAM(void); 58 | unsigned char* GetROM(void); 59 | unsigned char* GetZRAM(void); 60 | unsigned char* GetTilesCache(void); 61 | 62 | // 63 | bool m_IsRunning; 64 | bool m_IsPaused; 65 | bool m_RomLoaded; 66 | bool m_ReachedBreakPoint; 67 | int m_RomSize; 68 | 69 | unsigned int m_PreviousPC; 70 | unsigned int m_CurrentPC; 71 | 72 | t_mdinput *m_Inputs; 73 | 74 | // mdBreakPointList m_BreakPoints; 75 | 76 | /////////////////////////////////////////////////////////////////////////// 77 | protected: 78 | ////////// 79 | mdPlugin *m_Emu; 80 | mdDibBitmap *m_Bitmap; 81 | // mdVideoSurface *m_Bitmap; 82 | 83 | unsigned char *m_VDPRegs; 84 | 85 | 86 | }; 87 | 88 | /////////////////////////////////////////////////////////////////////////////// 89 | 90 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdFrmDumpBin.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdFrmDumpBin_H__ 2 | #define __mdFrmDumpBin_H__ 3 | 4 | class mdTextCtrl; 5 | 6 | /////////////////////////////////////////////////////////////////////////////// 7 | class mdFrmDumpBin : public wxDialog 8 | { 9 | /////////////////////////////////////////////////////////////////////////// 10 | public: 11 | /////// 12 | mdFrmDumpBin( wxWindow *frame, const wxChar *title); 13 | virtual ~mdFrmDumpBin(){}; 14 | 15 | void SetOptions(wxString& filename,int default_base,int length,int max_base,int max_lenght); 16 | 17 | int GetBaseAddress(); 18 | int GetLength(); 19 | 20 | /////////////////////////////////////////////////////////////////////////// 21 | private: 22 | //////// 23 | mdTextCtrl *m_BaseAddress; 24 | mdTextCtrl *m_Length; 25 | 26 | int MaxLength; 27 | int MaxBase; 28 | 29 | void OnClose(wxCloseEvent& event); 30 | void OnDump(wxCommandEvent& event); 31 | void OnCancel(wxCommandEvent& event); 32 | 33 | 34 | wxString *FileName; 35 | 36 | DECLARE_EVENT_TABLE() 37 | }; 38 | 39 | #endif 40 | /////////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /mdstudio/include/mdFrmGoto.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdFrmGoto_H__ 2 | #define __mdFrmGoto_H__ 3 | 4 | class mdGotoPanel; 5 | 6 | /////////////////////////////////////////////////////////////////////////////// 7 | class mdFrmGoto : public wxFrame 8 | { 9 | /////////////////////////////////////////////////////////////////////////// 10 | public: 11 | /////// 12 | mdFrmGoto(wxFrame *frame, const wxChar *title, 13 | int x, int y, int w, int h); 14 | virtual ~mdFrmGoto(){}; 15 | 16 | void OnGo( wxCommandEvent &event); 17 | 18 | /////////////////////////////////////////////////////////////////////////// 19 | private: 20 | //////// 21 | 22 | mdGotoPanel *m_GotoPanel; 23 | 24 | void OnClose(wxCloseEvent& event); 25 | 26 | 27 | DECLARE_EVENT_TABLE() 28 | }; 29 | 30 | #endif 31 | /////////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /mdstudio/include/mdFrmMain.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // 4 | 5 | #ifndef __MDFRMMAIN_H__ 6 | #define __MDFRMMAIN_H__ 7 | 8 | class mdEmu; 9 | class wxLayoutManager; 10 | class wxDockWindow; 11 | class mdVideoPanel; 12 | class mdDisAsmPanel; 13 | class mdCRAMPanel; 14 | class mdRegPanel; 15 | class mdSpiesPanel; 16 | class mdFrmVdpCalc; 17 | class mdFrmVdpAddrCalc; 18 | class mdFrmGoto; 19 | class mdVDPStatus; 20 | class mdLogPanel; 21 | class DXKeyboard; 22 | class mdVideoAdapter; 23 | class mdVideoSurface; 24 | class mdTileViewerPanel; 25 | 26 | /////////////////////////////////////////////////////////////////////////////// 27 | // 28 | class mdFrmMain : public wxFrame 29 | { 30 | /////////////////////////////////////////////////////////////////////////// 31 | public: 32 | /////// 33 | mdFrmMain( wxWindow *parent, const wxWindowID id, const wxString& title, 34 | const wxPoint& pos, const wxSize& size, const long style); 35 | ~mdFrmMain(); 36 | 37 | void StartSbProgress(const wxString &text,long maxvalue); 38 | void UpdateSbProgress(long value); 39 | void EndSbProgress(void); 40 | void SetStatusText(const wxString &text){ m_StatusBar->SetStatusText(text);} 41 | 42 | void Init(void); 43 | 44 | void EmulateFrame(void); 45 | 46 | void FlushLog(); 47 | void LogMessage(int level,char* text); 48 | void LogChar(int level,char text); 49 | 50 | void OnLoadRom(wxChar* filename); 51 | void OnLoadRom(wxChar* filename,bool clearSpies); 52 | 53 | void LoadLayout(); 54 | void SaveLayout(); 55 | 56 | void GotoAddress(int address); 57 | 58 | void UpdateDisAsm(void); 59 | 60 | mdDisAsmPanel* GetDisAsmPanel(void){ return m_DisAsmPanel;} 61 | mdSpiesPanel* GetSpiesPanel(void){ return m_SpiesPanel;} 62 | 63 | mdVideoAdapter *m_VideoAdapter; 64 | 65 | mdEmu* GetEmu(void){ return m_Emu;} 66 | 67 | /////////////////////////////////////////////////////////////////////////// 68 | protected: 69 | ////////// 70 | 71 | 72 | wxMenuBar *m_MenuBar; 73 | wxMenu *m_MenuFile; 74 | wxMenu *m_MenuDebug; 75 | wxMenu *m_MenuView; 76 | wxMenu *m_MenuDump; 77 | wxMenu *m_MenuTools; 78 | wxMenu *m_MenuEdit; 79 | wxMenu *m_MenuSymbols; 80 | wxMenu *m_MenuInputs; 81 | 82 | wxStatusBar *m_StatusBar; 83 | wxStatusBar *m_CustomStatusBar; 84 | wxPanel *m_PanelMain; 85 | 86 | mdFrmVdpCalc *m_FrmVdpCalc; 87 | mdFrmVdpAddrCalc *m_FrmVdpAddrCalc; 88 | mdFrmGoto *m_FrmGoto; 89 | 90 | wxLayoutManager *m_LayoutManager; 91 | wxDockWindow *m_VideoDock; 92 | // wxDockWindow *m_DisAsmDock; 93 | wxDockWindow *m_RegDock; 94 | wxDockWindow *m_SpiesDock; 95 | wxDockWindow *m_LogDock; 96 | wxDockWindow *m_VDPStatusDock; 97 | wxDockWindow *m_CRAMDock; 98 | wxDockWindow *m_TileViewerDock; 99 | 100 | mdVideoPanel *m_VideoPanel; 101 | mdDisAsmPanel *m_DisAsmPanel; 102 | mdRegPanel *m_RegPanel; 103 | mdSpiesPanel *m_SpiesPanel; 104 | mdLogPanel *m_LogPanel; 105 | mdVDPStatus *m_VDPStatus; 106 | mdCRAMPanel *m_CRAMPanel; 107 | mdTileViewerPanel *m_TileViewerPanel; 108 | 109 | bool m_EmuIsRunning; 110 | DWORD last_tick; 111 | 112 | DXKeyboard *m_DInput; 113 | mdEmu *m_Emu; 114 | 115 | void InitMenu(void); 116 | void InitLayout(void); 117 | 118 | void InitScreen(void); 119 | 120 | void OnQuit(wxCommandEvent& event); 121 | void OnLoadRom(wxCommandEvent& event); 122 | 123 | 124 | void OnReloadRom(wxCommandEvent& event); 125 | void OnRun(wxCommandEvent& event); 126 | void OnIdle(wxIdleEvent& event); 127 | 128 | void OnStepFrame(wxCommandEvent& event); 129 | void OnPause(wxCommandEvent& event); 130 | void OnStepInto(wxCommandEvent& event); 131 | 132 | void OnSaveScreenshot(wxCommandEvent& event); 133 | 134 | void OnDumpROM(wxCommandEvent& event); 135 | void OnDumpRAM(wxCommandEvent& event); 136 | void OnDumpCRAM(wxCommandEvent& event); 137 | void OnDumpVRAM(wxCommandEvent& event); 138 | void OnDumpZRAM(wxCommandEvent& event); 139 | void OnDumpVSRAM(wxCommandEvent& event); 140 | 141 | void OnVdpCalc(wxCommandEvent& event); 142 | void OnVdpAddrCalc(wxCommandEvent& event); 143 | 144 | void OnViewVideoRendering(wxCommandEvent& event); 145 | void OnViewLog(wxCommandEvent& event); 146 | void OnView68kRegisters(wxCommandEvent& event); 147 | void OnView68kWatchers(wxCommandEvent& event); 148 | void OnViewFullScreen(wxCommandEvent& event); 149 | void OnViewCRAM(wxCommandEvent& event); 150 | void OnViewVDPStatus(wxCommandEvent& event); 151 | 152 | void OnKeyDown(wxKeyEvent& event); 153 | void OnKeyUp(wxKeyEvent& event); 154 | 155 | void OnGotoAddress(wxCommandEvent& event); 156 | 157 | /////////////////////////////////////////////////////////////////////////// 158 | private: 159 | //////// 160 | 161 | DECLARE_EVENT_TABLE() 162 | }; 163 | 164 | /////////////////////////////////////////////////////////////////////////////// 165 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdFrmSpyAttr.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // 4 | 5 | #ifndef __mdFrmSpyAttr_H__ 6 | #define __mdFrmSpyAttr_H__ 7 | 8 | /////////////////////////////////////////////////////////////////////////////// 9 | // 10 | class mdTextCtrl; 11 | class mdSpiesPanel; 12 | 13 | class mdFrmSpyAttr : public wxDialog 14 | { 15 | /////////////////////////////////////////////////////////////////////////// 16 | public: 17 | /////// 18 | mdFrmSpyAttr( wxWindow *parent); 19 | ~mdFrmSpyAttr(); 20 | 21 | void SetSpiesPanel(mdSpiesPanel *panel); 22 | void SetUpdateSpy(mdSpy *spy); 23 | 24 | int m_InsertIndex; 25 | 26 | /////////////////////////////////////////////////////////////////////////// 27 | protected: 28 | ////////// 29 | 30 | int m_id; 31 | wxTextCtrl *m_TxtName; 32 | wxComboBox *m_CmbSize; 33 | wxComboBox *m_CmbArraySize; 34 | mdTextCtrl *m_TxtAddress; 35 | mdSpiesPanel *m_SpiesPanel; 36 | wxCheckBox *m_ChkHexa; 37 | 38 | wxButton *m_BtnOk; 39 | wxButton *m_BtnCancel; 40 | bool m_UpdateMode; 41 | 42 | void OnButton(wxCommandEvent& event); 43 | 44 | /////////////////////////////////////////////////////////////////////////// 45 | private: 46 | //////// 47 | 48 | DECLARE_EVENT_TABLE() 49 | }; 50 | 51 | /////////////////////////////////////////////////////////////////////////////// 52 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdFrmVDPAddrCalc.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdFrmVdpArrCalc_H__ 2 | #define __mdFrmVdpArrCalc_H__ 3 | 4 | class mdVdpAddrCalc; 5 | 6 | /////////////////////////////////////////////////////////////////////////////// 7 | class mdFrmVdpAddrCalc : public wxFrame 8 | { 9 | /////////////////////////////////////////////////////////////////////////// 10 | public: 11 | /////// 12 | mdFrmVdpAddrCalc(wxFrame *frame, const wxChar *title, 13 | int x, int y, int w, int h); 14 | virtual ~mdFrmVdpAddrCalc(){}; 15 | 16 | /////////////////////////////////////////////////////////////////////////// 17 | private: 18 | //////// 19 | 20 | mdVdpAddrCalc *m_VdpAddrCalc; 21 | 22 | void OnClose(wxCloseEvent& event); 23 | 24 | DECLARE_EVENT_TABLE() 25 | }; 26 | 27 | #endif 28 | /////////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /mdstudio/include/mdFrmVdpCalc.h: -------------------------------------------------------------------------------- 1 | #ifndef __MAINFRAME_H__ 2 | #define __MAINFRAME_H__ 3 | 4 | class mdVdpViewer; 5 | 6 | /////////////////////////////////////////////////////////////////////////////// 7 | class mdFrmVdpCalc : public wxFrame 8 | { 9 | /////////////////////////////////////////////////////////////////////////// 10 | public: 11 | /////// 12 | mdFrmVdpCalc(wxFrame *frame, const wxChar *title, 13 | int x, int y, int w, int h); 14 | virtual ~mdFrmVdpCalc(){}; 15 | 16 | /////////////////////////////////////////////////////////////////////////// 17 | private: 18 | //////// 19 | mdVdpViewer *m_Viewer; 20 | 21 | void OnClose(wxCloseEvent& event); 22 | 23 | DECLARE_EVENT_TABLE() 24 | }; 25 | 26 | #endif 27 | /////////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /mdstudio/include/mdGotoPanel.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdGotoPanel_H__ 2 | #define __mdGotoPanel_H__ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | // 6 | #include "mdTextCtrl.h" 7 | 8 | class mdGotoPanel : public wxPanel 9 | { 10 | /////////////////////////////////////////////////////////////////////////// 11 | public: 12 | /////// 13 | mdGotoPanel(wxWindow* parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL, const wxString& name = "panel"); 14 | virtual ~mdGotoPanel(); 15 | 16 | wxString GetAddress(){ return m_Address->GetValue();} 17 | 18 | /////////////////////////////////////////////////////////////////////////// 19 | private: 20 | //////// 21 | mdTextCtrl *m_Address; 22 | 23 | void OnGo( wxCommandEvent &event); 24 | 25 | DECLARE_EVENT_TABLE() 26 | 27 | }; 28 | 29 | #endif 30 | /////////////////////////////////////////////////////////////////////////////// 31 | -------------------------------------------------------------------------------- /mdstudio/include/mdListLine.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdListLine_H__ 2 | #define __mdListLine_H__ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | // Class definition 6 | /////////////////////////////////////////////////////////////////////////////// 7 | class mdListLine 8 | { 9 | /////////////////////////////////////////////////////////////////////////// 10 | public: 11 | /////// 12 | 13 | mdListLine(); 14 | ~mdListLine(); 15 | 16 | unsigned int pc; 17 | unsigned int page; 18 | wxString Text; 19 | 20 | /////////////////////////////////////////////////////////////////////////// 21 | protected: 22 | ////////// 23 | 24 | }; 25 | 26 | /////////////////////////////////////////////////////////////////////////////// 27 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdLogPanel.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdLogPanel_H__ 2 | #define __mdLogPanel_H__ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | // Class definition 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | class mdLogPanel: public wxPanel 9 | { 10 | /////////////////////////////////////////////////////////////////////////// 11 | public: 12 | /////// 13 | 14 | mdLogPanel( wxWindow* parent, 15 | wxWindowID id, 16 | const wxPoint& pos, 17 | const wxSize& size, 18 | long style, 19 | const wxString& name); 20 | ~mdLogPanel(); 21 | 22 | void Flush(void); 23 | void LogMessage(int level,char* text); 24 | void LogChar(int level,char text); 25 | 26 | 27 | /////////////////////////////////////////////////////////////////////////// 28 | protected: 29 | ////////// 30 | 31 | wxMenu *m_Popup; 32 | wxPanel *m_LogDisplay; 33 | 34 | int m_Cnt; 35 | int m_ScrollPosition; 36 | int m_LastIndex; 37 | 38 | wxString m_Text[512]; 39 | int m_Level[512]; 40 | int m_LevelShow[10]; 41 | 42 | void OnPaint(wxPaintEvent& event); 43 | void OnEraseBackground(wxEraseEvent& event); 44 | 45 | void OnContextMenu(wxContextMenuEvent& event); 46 | 47 | void OnClearLog(wxCommandEvent& event); 48 | void OnSaveLog(wxCommandEvent& event); 49 | void OnDMA(wxCommandEvent& event); 50 | void OnIO(wxCommandEvent& event); 51 | 52 | void OnThumbTrack(wxScrollWinEvent &event); 53 | void OnSize(wxSizeEvent &event); 54 | 55 | DECLARE_EVENT_TABLE() 56 | }; 57 | 58 | /////////////////////////////////////////////////////////////////////////////// 59 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdOutputDataPlugin.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdOutputDataPlugin_H__ 2 | #define __mdOutputDataPlugin_H__ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | // Class definition 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | #include "include/mdSDK.h" 9 | class mdDefaultPlugin; 10 | 11 | class mdOutputDataPlugin:public mdDefaultPlugin 12 | { 13 | /////////////////////////////////////////////////////////////////////////// 14 | public: 15 | /////// 16 | 17 | mdOutputDataPlugin(const wxString& filename); 18 | ~mdOutputDataPlugin(); 19 | 20 | int GetOutputType(void); 21 | int OutputPicture(wxString &filename,mdPictureInfo *info,unsigned char* pixels,mdColor *pal); 22 | 23 | /////////////////////////////////////////////////////////////////////////// 24 | protected: 25 | ////////// 26 | 27 | typedef int (*fctGetOutputType)(void); 28 | typedef int (*fctOutputPicture)(const char *filename,mdPictureInfo *info,unsigned char* pixels,mdColor *pal); 29 | 30 | void GetSymbols(void); 31 | 32 | fctGetOutputType m_fctGetOuputType; 33 | fctOutputPicture m_fctOutputPicture; 34 | 35 | }; 36 | 37 | /////////////////////////////////////////////////////////////////////////////// 38 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdPlugin.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdPlugin_H__ 2 | #define __mdPlugin_H__ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | // Class definition 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | class wxDynamicLibrary; 9 | 10 | #include "include/mdSDK.h" 11 | 12 | class mdPlugin 13 | { 14 | /////////////////////////////////////////////////////////////////////////// 15 | public: 16 | /////// 17 | 18 | mdPlugin(const wxString& filename); 19 | ~mdPlugin(); 20 | 21 | int LoadRom(const wxString &filename); 22 | void GetVideoBufferAttr(int *w,int *h,int *bpp,int *rgbformat); 23 | unsigned int InitEmulator(unsigned char*videobuffer,int bpp); 24 | int RunFrame(int tick); 25 | void CloseEmulator(void); 26 | int StepInto(int t); 27 | unsigned int DisAsm(char* buff,unsigned int pc); 28 | void GetRomInfo(t_RomInfo *info); 29 | unsigned int GetCpuRegister(int cpu_id,int reg_id); 30 | void SetCallBack(t_Callbacks* calls); 31 | 32 | unsigned int M68K_ReadMemory8(unsigned int addr); 33 | unsigned int M68K_ReadMemory16(unsigned int addr); 34 | unsigned int M68K_ReadMemory32(unsigned int addr); 35 | 36 | t_mdinput* GetInput(void); 37 | unsigned char* GetVDPRegisters(void); 38 | 39 | unsigned char* GetCRAM(void); 40 | unsigned char* GetVSRAM(void); 41 | unsigned char* GetVRAM(void); 42 | 43 | unsigned char* GetRAM(void); 44 | unsigned char* GetROM(void); 45 | unsigned char* GetZRAM(void); 46 | unsigned char* GetTilesCache(void); 47 | 48 | int GenerateScreenshot(mdPictureInfo *info,unsigned char* pixels,mdColor *pal); 49 | 50 | /////////////////////////////////////////////////////////////////////////// 51 | protected: 52 | ////////// 53 | 54 | typedef int(*fctLoadRom)(char* rom); 55 | typedef void (*fctGetVideoBufferAttr)(int *w,int *h,int *bpp,int *rgbformat); 56 | typedef unsigned int (*fctInitEmulator)(unsigned char*videobuffer,int bpp); 57 | typedef void (*fctCloseEmulator)(void); 58 | typedef void (*fctGetRomInfo)(t_RomInfo*); 59 | typedef int (*fctStepInto)(int t); 60 | typedef int (*fctRunFrame)(int tick); 61 | typedef unsigned int (*fctDisAsm)(char* buff,unsigned int pc); 62 | typedef unsigned int (*fctGetCpuRegister)(int cpu_id,int reg_id); 63 | typedef void (*fctSetCallBack)(t_Callbacks* calls); 64 | typedef t_mdinput* (*fctGetInput)(void); 65 | typedef unsigned char* (*fctGetVDPRegisters)(void); 66 | typedef unsigned char* (*fctGetVRAM)(void); 67 | typedef unsigned char* (*fctGetCRAM)(void); 68 | typedef unsigned char* (*fctGetVSRAM)(void); 69 | 70 | typedef unsigned char* (*fctGetROM)(void); 71 | typedef unsigned char* (*fctGetRAM)(void); 72 | typedef unsigned char* (*fctGetZRAM)(void); 73 | typedef unsigned char* (*fctGetTilesCache)(void); 74 | 75 | typedef int (*fctGenerateScreenshot)(mdPictureInfo *info,unsigned char* pixels,mdColor *pal); 76 | 77 | typedef unsigned int (*fctm68kReadMemory8)(unsigned int address); 78 | typedef unsigned int (*fctm68kReadMemory16)(unsigned int address); 79 | typedef unsigned int (*fctm68kReadMemory32)(unsigned int address); 80 | 81 | wxString m_FileName; 82 | wxDynamicLibrary *m_Library; 83 | 84 | fctLoadRom m_fctLoadRom; 85 | fctGetVideoBufferAttr m_fctGetVideoBufferAttr; 86 | fctInitEmulator m_fctInitEmulator; 87 | fctRunFrame m_fctRunFrame; 88 | fctCloseEmulator m_fctCloseEmulator; 89 | fctGetRomInfo m_fctGetRomInfo; 90 | fctStepInto m_fctStepInto; 91 | fctDisAsm m_fctDisAsm; 92 | fctGetCpuRegister m_fctGetCpuRegister; 93 | fctSetCallBack m_fctSetCallBack; 94 | fctGetInput m_fctGetInput; 95 | 96 | fctGetVDPRegisters m_fctGetVDPRegisters; 97 | fctGetVRAM m_fctGetVRAM; 98 | fctGetCRAM m_fctGetCRAM; 99 | fctGetVSRAM m_fctGetVSRAM; 100 | 101 | fctGetROM m_fctGetROM; 102 | fctGetRAM m_fctGetRAM; 103 | fctGetZRAM m_fctGetZRAM; 104 | fctGetTilesCache m_fctGetTileCache; 105 | 106 | fctGenerateScreenshot m_fctGenerateScreenshot; 107 | 108 | fctm68kReadMemory8 m_fctm68kReadMemory8; 109 | fctm68kReadMemory16 m_fctm68kReadMemory16; 110 | fctm68kReadMemory32 m_fctm68kReadMemory32; 111 | 112 | 113 | void GetSymbols(void); 114 | 115 | }; 116 | 117 | /////////////////////////////////////////////////////////////////////////////// 118 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdPluginList.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // mdPluginsList 3 | // 4 | // 5 | // 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | #ifndef __mdPLUGINSLIST_H__ 9 | #define __mdPlUGINSLIST_H__ 10 | 11 | /////////////////////////////////////////////////////////////////////////////// 12 | // Include 13 | 14 | #include "mdList.h" 15 | 16 | /////////////////////////////////////////////////////////////////////////////// 17 | // Class definition 18 | 19 | template class mdPluginsList 20 | { 21 | /////////////////////////////////////////////////////////////////////////// 22 | public: 23 | /////// 24 | 25 | mdPluginsList(const wxString &path,const wxString &wildcard); 26 | ~mdPluginsList(); 27 | 28 | int GetCount(void); 29 | T* Item(int index); 30 | 31 | /////////////////////////////////////////////////////////////////////////// 32 | protected: 33 | ////////// 34 | 35 | wxString m_Wildcard; 36 | wxString m_Path; 37 | mdList *m_List; 38 | 39 | void Load(void); 40 | 41 | /////////////////////////////////////////////////////////////////////////// 42 | private: 43 | //////// 44 | }; 45 | 46 | /////////////////////////////////////////////////////////////////////////////// 47 | // Constructor 48 | 49 | template 50 | mdPluginsList::mdPluginsList(const wxString &path, 51 | const wxString &wildcard) 52 | { 53 | m_Path=path; 54 | m_Wildcard=wildcard; 55 | 56 | m_List=new mdList; 57 | 58 | if(m_Path.IsEmpty()==false && m_Wildcard.IsEmpty()==false) 59 | Load(); 60 | } 61 | 62 | /////////////////////////////////////////////////////////////////////////////// 63 | // Destructor 64 | 65 | template 66 | mdPluginsList::~mdPluginsList(void) 67 | { 68 | mdPlugin *p; 69 | while( (p=m_List->PopBack())!=NULL) 70 | { delete(p);} 71 | } 72 | 73 | /////////////////////////////////////////////////////////////////////////////// 74 | // Number of plugins 75 | 76 | template 77 | int mdPluginsList::GetCount(void) 78 | { 79 | return m_List->GetCount(); 80 | } 81 | 82 | /////////////////////////////////////////////////////////////////////////////// 83 | // Load plugins 84 | 85 | template 86 | void mdPluginsList::Load(void) 87 | { 88 | wxString path(m_Path + m_Wildcard); 89 | 90 | wxString current = wxFindFirstFile(path,wxFILE); 91 | while (!current.IsEmpty()) 92 | { 93 | m_List->PushBack(new T(current)); 94 | current=wxFindNextFile(); 95 | } 96 | } 97 | 98 | /////////////////////////////////////////////////////////////////////////////// 99 | // Return the object at that index 100 | 101 | template 102 | T* mdPluginsList::Item(int index) 103 | { 104 | return m_List->Item(index); 105 | } 106 | 107 | /////////////////////////////////////////////////////////////////////////////// 108 | // 109 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdProgressStatusBar.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdProgressStatusBar_H__ 2 | #define __mdProgressStatusBar_H__ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | // Class definition 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | class mdProgressStatusBar: public wxStatusBar 9 | { 10 | /////////////////////////////////////////////////////////////////////////// 11 | public: 12 | /////// 13 | 14 | mdProgressStatusBar(wxWindow *parent,const wxString &text,long maxvalue); 15 | ~mdProgressStatusBar(); 16 | 17 | void SetValue(long value){ m_Gauge->SetValue(value);} 18 | void SendSizeEvent(void); 19 | 20 | /////////////////////////////////////////////////////////////////////////// 21 | protected: 22 | ////////// 23 | 24 | long m_MaxValue; 25 | wxGauge *m_Gauge; 26 | 27 | void OnSize(wxSizeEvent& event); 28 | 29 | 30 | DECLARE_EVENT_TABLE() 31 | }; 32 | 33 | /////////////////////////////////////////////////////////////////////////////// 34 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdProject.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdProject_H__ 2 | #define __mdProject_H__ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | // Class definition 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | class mdSpy; 9 | class mdBreakPoint; 10 | class mdSymbol; 11 | class mdSymbolPair; 12 | class mdSection; 13 | class mdListLine; 14 | 15 | /////////////////////////////////////////////////////////////////////////////// 16 | 17 | WX_DECLARE_HASH_MAP(int, mdSpy*, wxIntegerHash, wxIntegerEqual, mdSpiesList ); 18 | WX_DECLARE_HASH_MAP( int, mdBreakPoint*, wxIntegerHash, wxIntegerEqual, mdBreakPointList ); 19 | WX_DECLARE_HASH_MAP( int, mdSymbolPair*, wxIntegerHash, wxIntegerEqual, mdSymbolList ); 20 | 21 | WX_DECLARE_HASH_MAP( int, mdListLine*, wxIntegerHash, wxIntegerEqual, mdListLinePC ); 22 | WX_DECLARE_HASH_MAP( int, mdListLine*, wxIntegerHash, wxIntegerEqual, mdListLinePage ); 23 | 24 | /////////////////////////////////////////////////////////////////////////////// 25 | 26 | class mdProject 27 | { 28 | /////////////////////////////////////////////////////////////////////////// 29 | public: 30 | /////// 31 | mdProject(); 32 | ~mdProject(); 33 | 34 | // Watchers 35 | mdSpy* InsertSpy( int IntIndex, 36 | mdSection *Section, 37 | wxString &name, 38 | unsigned int address, 39 | int length, 40 | bool isfromarray); 41 | mdSpy* GetSpy(int IntIndex); 42 | void RemoveSpy(int IntIndex); 43 | void ClearAllSpies(void); 44 | int CountSpies(void); 45 | 46 | // BreakPoints 47 | mdBreakPoint* InsertBreakPoint(int IntIndex); 48 | mdBreakPoint* GetBreakPoint(int pc); 49 | void ClearAllBreakPoints(void); 50 | void RemoveBreakPoint(int IntIndex); 51 | int CountBreakPoint(void); 52 | int ExecuteBreakPoint(int pc); 53 | bool CheckGotBreakPoint(int pc); 54 | 55 | // Symbols 56 | mdSymbol* InsertSymbol(mdSection *Section_ID,wxString &Name,unsigned int Address,int Type,bool CreeParUser); 57 | void ClearAllSymbols(void); 58 | int CountSymbols(void); 59 | mdSymbol* GetSymbol(int type,int pc); 60 | char* GetSymbolLabelName(int pc); 61 | char* GetSymbolVariableName(int pc); 62 | 63 | mdSymbolPair* GetSymbolPair(int pc); 64 | bool CheckSymbolPairExist(int pc); 65 | 66 | void RemoveSymbol(int type,int pc); 67 | 68 | char* GetSymbolName(int pc); 69 | 70 | int LoadSymbols(int type,wxString& FileName); 71 | int mdProject::LoadList(wxString& FileName); 72 | 73 | void AddDefaultSymbols(void); 74 | 75 | wxString DumpFile_Rom; 76 | wxString DumpFile_68kRam; 77 | wxString DumpFile_Z80Ram; 78 | wxString DumpFile_CRam; 79 | wxString DumpFile_VRam; 80 | wxString DumpFile_VSRam; 81 | 82 | /////////////////////////////////////////////////////////////////////////// 83 | protected: 84 | ////////// 85 | 86 | mdSpiesList m_Spies; 87 | mdBreakPointList m_BreakPoints; 88 | mdSymbolList m_Symbols; 89 | 90 | mdListLinePC m_ListLinePC; 91 | mdListLinePage m_ListLinePage; 92 | 93 | 94 | 95 | }; 96 | 97 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdProxy.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdProxy_H__ 2 | #define __mdProxy_H__ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | extern int CheckBreakPoint(unsigned int pc); 7 | extern void SetBreakPoint(unsigned int pc); 8 | 9 | extern void LogMessage(int src,char* msg); 10 | extern char* GetSymbolName(int type,unsigned int pc); 11 | 12 | extern void LogChar(char msg); 13 | 14 | /////////////////////////////////////////////////////////////////////////////// 15 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdRegPanel.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdRegPanel_H__ 2 | #define __mdRegPanel_H__ 3 | 4 | class mdRegistersDisplay; 5 | class mdEmu; 6 | 7 | /////////////////////////////////////////////////////////////////////////////// 8 | // Class definition 9 | /////////////////////////////////////////////////////////////////////////////// 10 | 11 | class mdRegPanel: public wxPanel 12 | { 13 | /////////////////////////////////////////////////////////////////////////// 14 | public: 15 | /////// 16 | 17 | mdRegPanel( wxWindow* parent, 18 | wxWindowID id, 19 | const wxPoint& pos, 20 | const wxSize& size, 21 | long style, 22 | const wxString& name); 23 | ~mdRegPanel(); 24 | 25 | void SetCpuType(int id); 26 | void SetEmu(mdEmu *emu); 27 | void UpdadeRegisters(void); 28 | 29 | /////////////////////////////////////////////////////////////////////////// 30 | protected: 31 | ////////// 32 | 33 | mdRegistersDisplay *m_RegsDisplay; 34 | mdEmu *m_Emu; 35 | 36 | wxCheckBox *m_ChkC; 37 | wxCheckBox *m_ChkV; 38 | wxCheckBox *m_ChkZ; 39 | wxCheckBox *m_ChkN; 40 | wxCheckBox *m_ChkX; 41 | 42 | DECLARE_EVENT_TABLE() 43 | }; 44 | 45 | /////////////////////////////////////////////////////////////////////////////// 46 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdRegistersDisplay.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdRegistersDisplay_H__ 2 | #define __mdRegistersDisplay_H__ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | // Class definition 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | class mdEmu; 9 | 10 | class mdRegistersDisplay: public wxPanel 11 | { 12 | /////////////////////////////////////////////////////////////////////////// 13 | public: 14 | /////// 15 | 16 | mdRegistersDisplay( wxWindow* parent, 17 | wxWindowID id, 18 | const wxPoint& pos, 19 | const wxSize& size, 20 | long style, 21 | const wxString& name); 22 | ~mdRegistersDisplay(); 23 | void SetCpuType(int cpu_id); 24 | void UpdateRegisters(); 25 | 26 | void SetEmu(mdEmu *emu); 27 | unsigned int GetSR(void); 28 | 29 | /////////////////////////////////////////////////////////////////////////// 30 | protected: 31 | ////////// 32 | 33 | int m_Position; 34 | int m_CpuType; 35 | wxString m_Registers[20]; 36 | int m_NbRegs; 37 | mdEmu* m_Emu; 38 | unsigned int m_SR; 39 | 40 | void OnPaint(wxPaintEvent& event); 41 | void OnEraseBackground(wxEraseEvent& event); 42 | 43 | DECLARE_EVENT_TABLE() 44 | }; 45 | 46 | /////////////////////////////////////////////////////////////////////////////// 47 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdSDK.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdSDK_H__ 2 | #define __mdSDK_H__ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | // Data type 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | /*typedef unsigned char uint8; 9 | typedef unsigned short int uint16; 10 | typedef unsigned long int uint32; 11 | 12 | typedef signed char int8; 13 | typedef signed short int int16; 14 | typedef signed long int int32; 15 | */ 16 | /////////////////////////////////////////////////////////////////////////////// 17 | // define 18 | 19 | #define mdERR_UNKNOWN 0 20 | #define mdOK 1 21 | #define mdKO 0 22 | 23 | #define mdERR_OUTMEMORY 50 24 | #define mdERR_OPENINGFILE 51 25 | #define mdERR_SAVINGFILE 52 26 | #define mdERR_BADBPP 53 27 | #define mdERR_UNSUPPORTED 54 28 | #define mdERR_FILEUNSUPPORTED 55 29 | #define mdERR_COPYDATA 56 30 | #define mdERR_NOOUTPUT 57 31 | #define mdERR_NOINPUT 58 32 | #define mdERR_COMPRESSION 59 33 | 34 | #define mdMAX_COLORS 256 35 | #define DLLEXPORT extern "C" __declspec(dllexport) 36 | 37 | typedef int (*fctCheckBreakPoint)(unsigned int pc); 38 | typedef void (*fctSetBreakPoint)(unsigned int pc); 39 | typedef void (*fctLogMessage)(int src,char *msg); 40 | typedef void (*fctLogChar)(char msg); 41 | typedef char* (*fctGetSymbolName)(int type,unsigned int pc); 42 | 43 | /////////////////////////////////////////////////////////////////////////////// 44 | // Structures 45 | 46 | typedef struct{ 47 | char Name[256]; 48 | int size; 49 | }t_RomInfo; 50 | 51 | typedef struct{ 52 | fctCheckBreakPoint m_fctCheckBreakPoint; 53 | fctSetBreakPoint m_fctSetBreakPoint; 54 | fctLogMessage m_fctLogMessage; 55 | fctLogChar m_fctLogChar; 56 | fctGetSymbolName m_fctGetSymbolName; 57 | 58 | }t_Callbacks; 59 | 60 | typedef struct 61 | { 62 | //unsigned char dev[8]; /* Can be any of the DEVICE_* values */ 63 | //unsigned long pad[8]; /* Can be any of the INPUT_* bitmasks */ 64 | //unsigned long system; /* Can be any of the SYSTEM_* bitmasks */ 65 | unsigned char dev[8]; /* Can be any of the DEVICE_* values */ 66 | unsigned long pad[8]; /* Can be any of the INPUT_* bitmasks */ 67 | unsigned char padtype[8]; /* 3BUTTONS or 6BUTTONS gamepad */ 68 | unsigned char system[2]; /* Can be any of the SYSTEM_* bitmasks */ 69 | unsigned char max; /* maximum number of connected devices */ 70 | unsigned char current; /* current PAD number (4WAYPLAY) */ 71 | int analog[3][2]; /* analog devices */ 72 | int x_offset; 73 | int y_offset; 74 | }t_mdinput; 75 | 76 | /* 77 | typedef struct{ 78 | unsigned char *ram, 79 | unsigned char *rom, 80 | unsigned char *vram, 81 | unsigned char *vsram, 82 | unsigned char *cram, 83 | unsigned char *vdp_reg[20] 84 | }t_Memory; 85 | */ 86 | typedef struct 87 | { int Width; 88 | int Height; 89 | int BytesPerPixel; 90 | int Pitch; 91 | }mdPictureInfo; 92 | 93 | typedef struct 94 | { unsigned char Alpha; 95 | unsigned char Red,Green,Blue; 96 | }mdColor; 97 | 98 | #define mdOutputType_Raw 0 99 | #define mdOutputType_Picture 1 100 | 101 | /////////////////////////////////////////////////////////////////////////////// 102 | // Registres 103 | 104 | #define mdM68K_CPU 0 105 | #define mdM68K_REG_PC 0 106 | #define mdM68K_REG_D0 1 107 | #define mdM68K_REG_D1 2 108 | #define mdM68K_REG_D2 3 109 | #define mdM68K_REG_D3 4 110 | #define mdM68K_REG_D4 5 111 | #define mdM68K_REG_D5 6 112 | #define mdM68K_REG_D6 7 113 | #define mdM68K_REG_D7 8 114 | #define mdM68K_REG_A0 9 115 | #define mdM68K_REG_A1 10 116 | #define mdM68K_REG_A2 11 117 | #define mdM68K_REG_A3 12 118 | #define mdM68K_REG_A4 13 119 | #define mdM68K_REG_A5 14 120 | #define mdM68K_REG_A6 15 121 | #define mdM68K_REG_A7 16 122 | #define mdM68K_REG_SR 17 123 | #define mdM68K_REG_SP 16 124 | 125 | #define mdINPUT_MODE (0x00000800) 126 | #define mdINPUT_Z (0x00000400) 127 | #define mdINPUT_Y (0x00000200) 128 | #define mdINPUT_X (0x00000100) 129 | #define mdINPUT_START (0x00000080) 130 | #define mdINPUT_C (0x00000040) 131 | #define mdINPUT_B (0x00000020) 132 | #define mdINPUT_A (0x00000010) 133 | #define mdINPUT_LEFT (0x00000008) 134 | #define mdINPUT_RIGHT (0x00000004) 135 | #define mdINPUT_DOWN (0x00000002) 136 | #define mdINPUT_UP (0x00000001) 137 | 138 | 139 | 140 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdScreen.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdScreen_H__ 2 | #define __mdScreen_H__ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | // Class definition 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | class mdDibBitmap; 9 | class mdVideoAdapter; 10 | class mdVideoSurface; 11 | 12 | class mdScreen: public wxPanel 13 | { 14 | /////////////////////////////////////////////////////////////////////////// 15 | public: 16 | /////// 17 | 18 | mdScreen( wxWindow* parent, 19 | wxWindowID id, 20 | const wxPoint& pos, 21 | const wxSize& size, 22 | long style, 23 | const wxString& name); 24 | ~mdScreen(); 25 | 26 | void SetBitmap(mdDibBitmap *bmp); 27 | 28 | /////////////////////////////////////////////////////////////////////////// 29 | protected: 30 | ////////// 31 | 32 | mdDibBitmap *m_Bitmap; 33 | mdVideoSurface *m_Surface; 34 | 35 | void OnEraseBackground(wxEraseEvent& event); 36 | void OnPaint(wxPaintEvent& event); 37 | 38 | int m_Zoom; 39 | 40 | 41 | DECLARE_EVENT_TABLE() 42 | }; 43 | 44 | /////////////////////////////////////////////////////////////////////////////// 45 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdSection.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdSection_H__ 2 | #define __mdSection_H__ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | // Class definition 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | class mdSection 9 | { 10 | /////////////////////////////////////////////////////////////////////////// 11 | public: 12 | /////// 13 | 14 | mdSection(); 15 | ~mdSection(); 16 | 17 | unsigned int Base; 18 | wxString Name; 19 | 20 | /////////////////////////////////////////////////////////////////////////// 21 | protected: 22 | ////////// 23 | 24 | 25 | }; 26 | 27 | /////////////////////////////////////////////////////////////////////////////// 28 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdShared.h: -------------------------------------------------------------------------------- 1 | #ifndef __MDSHARED_H__ 2 | #define __MDSHARED_H__ 3 | 4 | //#include "windows.h" 5 | 6 | #include "wx/wxprec.h" 7 | #ifndef WX_PRECOMP 8 | #include "wx/wx.h" 9 | #include "wx/app.h" 10 | #include "wx/frame.h" 11 | #include "wx/menu.h" 12 | #endif 13 | 14 | #include "wx/layoutmanager.h" 15 | #include "wx/dockwindow.h" 16 | #include "wx/dockhost.h" 17 | #include "wx/pane.h" 18 | #include "wx/util.h" 19 | #include "wx/slidebar.h" 20 | #include "wx/toolbutton.h" 21 | #include "wx/toolbar.h" 22 | #include "wx/dcbuffer.h" 23 | #include "wx/dynlib.h" 24 | #include "wx/listctrl.h" 25 | #include 26 | #include 27 | #include 28 | #include 29 | /* 30 | #include "wx/layoutmanager.h" 31 | #include "wx/dockwindow.h" 32 | #include "wx/dockhost.h" 33 | #include "wx/pane.h" 34 | #include "wx/util.h" 35 | #include "wx/slidebar.h" 36 | #include "wx/toolbutton.h" 37 | #include "wx/toolbar.h" 38 | */ 39 | 40 | 41 | #include "mdSDK.h" 42 | 43 | 44 | 45 | #define APP_TITLE "Megadrive Developper Studio" 46 | 47 | #define gApp wxGetApp() 48 | #define gFrmMain gApp.GetFrmMain() 49 | #define gEmu gApp.GetFrmMain()->GetEmu() 50 | #define gProject gApp.GetProject() 51 | #define gVideoAdapter gApp.GetFrmMain()->m_VideoAdapter 52 | 53 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdSpiesPanel.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdSpiesPanel_H__ 2 | #define __mdSpiesPanel_H__ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | // Class definition 6 | /////////////////////////////////////////////////////////////////////////////// 7 | class mdSpy; 8 | class mdEmu; 9 | class mdSection; 10 | 11 | 12 | class mdSpiesPanel: public wxPanel 13 | { 14 | /////////////////////////////////////////////////////////////////////////// 15 | public: 16 | /////// 17 | 18 | mdSpiesPanel( wxWindow* parent, 19 | wxWindowID id, 20 | const wxPoint& pos, 21 | const wxSize& size, 22 | long style, 23 | const wxString& name); 24 | ~mdSpiesPanel(); 25 | 26 | mdSpy* InsertSpy(int list_idx,mdSection *Section_ID,wxString &name,unsigned int address,int length,int arraycnt=1,bool isarrayelement=false); 27 | mdSpy* InsertSpy(mdSection *Section_ID,wxString &name,unsigned int address,int length,int arraycnt=1,bool isarrayelement=false); 28 | long GetSelectedIndex(); 29 | 30 | void ProcessItem(bool Update,mdSpy* spy); 31 | void ProcessItem(int list_idx,bool Update,mdSpy* spy); 32 | 33 | void UpdateSpies(bool force=FALSE); 34 | 35 | void SetEmu(mdEmu* emu); 36 | 37 | void Clear(void); 38 | 39 | /////////////////////////////////////////////////////////////////////////// 40 | protected: 41 | ////////// 42 | 43 | 44 | wxMenu *m_Popup; 45 | wxListCtrl *m_SpiesList; 46 | mdEmu* m_Emu; 47 | void SelectSpy(wxListEvent& event); 48 | 49 | void OnContextMenu(wxContextMenuEvent& event); 50 | 51 | void OnAddSpy(wxCommandEvent& event); 52 | void OnUpdateSpy(wxCommandEvent& event); 53 | void OnDeleteSpy(wxCommandEvent& event); 54 | void OnInsertSpy(wxCommandEvent& event); 55 | 56 | void OnDisplayHexa(wxCommandEvent& event); 57 | 58 | DECLARE_EVENT_TABLE() 59 | }; 60 | 61 | /////////////////////////////////////////////////////////////////////////////// 62 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdSpy.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdSpy_H__ 2 | #define __mdSpy_H__ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | // Class definition 6 | /////////////////////////////////////////////////////////////////////////////// 7 | class mdSymbol; 8 | 9 | class mdSpy 10 | { 11 | /////////////////////////////////////////////////////////////////////////// 12 | public: 13 | /////// 14 | 15 | mdSpy(); 16 | ~mdSpy(); 17 | 18 | //unsigned int Address; 19 | //wxString Name; 20 | //int ListIndex; 21 | //int Type; 22 | //mdSymbol* Other; 23 | 24 | int m_Length; 25 | int m_ListIndex; 26 | int m_ArraySize; 27 | unsigned int m_Value; 28 | bool m_IsFromArray; 29 | bool m_DisplayHexa; 30 | mdSymbol *m_Symbol; 31 | 32 | void SetName(wxString &name); 33 | void SetAddress(int address,bool UpdateSymbol); 34 | wxString& GetName(void); 35 | int GetAddress(void); 36 | 37 | /////////////////////////////////////////////////////////////////////////// 38 | protected: 39 | ////////// 40 | unsigned int m_Address; 41 | wxString m_Name; 42 | 43 | }; 44 | 45 | /////////////////////////////////////////////////////////////////////////////// 46 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdSymbol.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdSymbol_H__ 2 | #define __mdSymbol_H__ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | // Class definition 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | class mdSection; 9 | 10 | class mdSymbol 11 | { 12 | /////////////////////////////////////////////////////////////////////////// 13 | public: 14 | /////// 15 | 16 | mdSymbol(); 17 | ~mdSymbol(); 18 | 19 | mdSection *Section; 20 | unsigned int Address; 21 | unsigned int Displacement; 22 | wxString Name; 23 | bool UserCreated; 24 | 25 | /////////////////////////////////////////////////////////////////////////// 26 | protected: 27 | ////////// 28 | 29 | }; 30 | 31 | /////////////////////////////////////////////////////////////////////////////// 32 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdSymbolPair.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdSymbolPair_H__ 2 | #define __mdSymbolPair_H__ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | // Class definition 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | class mdSymbolPair 9 | { 10 | /////////////////////////////////////////////////////////////////////////// 11 | public: 12 | /////// 13 | 14 | mdSymbolPair(); 15 | ~mdSymbolPair(); 16 | 17 | mdSymbol* Label; 18 | mdSymbol* Variable; 19 | 20 | /////////////////////////////////////////////////////////////////////////// 21 | protected: 22 | ////////// 23 | 24 | }; 25 | 26 | /////////////////////////////////////////////////////////////////////////////// 27 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdSymbolsPanel.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdSymbolsPanel_H__ 2 | #define __mdSymbolsPanel_H__ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | // Class definition 6 | /////////////////////////////////////////////////////////////////////////////// 7 | class mdSymbol; 8 | class mdEmu; 9 | class mdSection; 10 | 11 | class mdSymbolsPanel: public wxPanel 12 | { 13 | /////////////////////////////////////////////////////////////////////////// 14 | public: 15 | /////// 16 | 17 | mdSymbolsPanel( wxWindow* parent, 18 | wxWindowID id, 19 | const wxPoint& pos, 20 | const wxSize& size, 21 | long style, 22 | const wxString& name); 23 | ~mdSymbolsPanel(); 24 | 25 | /////////////////////////////////////////////////////////////////////////// 26 | protected: 27 | ////////// 28 | 29 | 30 | wxMenu *m_Popup; 31 | wxListCtrl *m_SymbolsList; 32 | DECLARE_EVENT_TABLE() 33 | }; 34 | 35 | /////////////////////////////////////////////////////////////////////////////// 36 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdTextCtrl.h: -------------------------------------------------------------------------------- 1 | #ifndef __HEXATEXTBOX_H__ 2 | #define __HEXATEXTBOX_H__ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | class mdTextCtrl:public wxTextCtrl 6 | { 7 | /////////////////////////////////////////////////////////////////////////// 8 | protected: 9 | ////////// 10 | 11 | /////////////////////////////////////////////////////////////////////////// 12 | public: 13 | /////// 14 | mdTextCtrl(wxWindow* parent, wxWindowID id, const wxString& value = "", const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxTextCtrlNameStr); 15 | 16 | virtual ~mdTextCtrl(){} 17 | 18 | void OnKeydown(wxKeyEvent& event); 19 | void OnContextMenu(wxContextMenuEvent& event); 20 | 21 | DECLARE_EVENT_TABLE() 22 | }; 23 | 24 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdTileViewerPanel.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // 4 | // 5 | // 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | #ifndef __mdTileViewerPanel_H__ 9 | #define __mdTileViewerPanel_H__ 10 | 11 | /////////////////////////////////////////////////////////////////////////////// 12 | // Class definition 13 | /////////////////////////////////////////////////////////////////////////////// 14 | 15 | class mdDibBitmap; 16 | class mdVideoAdapter; 17 | class mdVideoSurface; 18 | 19 | class mdTileViewerPanel: public wxWindow 20 | { 21 | /////////////////////////////////////////////////////////////////////////// 22 | public: 23 | /////// 24 | 25 | mdTileViewerPanel( wxWindow* parent, 26 | wxWindowID id = -1, 27 | const wxPoint& pos = wxDefaultPosition, 28 | const wxSize& size = wxDefaultSize, 29 | long style =wxSIMPLE_BORDER , 30 | const wxString& name = "ScrollPanel"); 31 | 32 | ~mdTileViewerPanel(); 33 | 34 | /////////////////////////////////////////////////////////////////////////// 35 | protected: 36 | ////////// 37 | 38 | void OnEraseBackground(wxEraseEvent &event); 39 | void OnPaint(wxPaintEvent& event); 40 | 41 | /////////////////////////////////////////////////////////////////////////// 42 | private: 43 | //////// 44 | 45 | mdVideoSurface *m_Surface; 46 | 47 | DECLARE_EVENT_TABLE() 48 | }; 49 | 50 | /////////////////////////////////////////////////////////////////////////////// 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /mdstudio/include/mdVDPStatusPanel.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdVDPStatusPanel_H__ 2 | #define __mdVDPStatusPanel_H__ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | // Class definition 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | class mdEmu; 9 | 10 | class mdVDPStatus: public wxPanel 11 | { 12 | /////////////////////////////////////////////////////////////////////////// 13 | public: 14 | /////// 15 | 16 | mdVDPStatus( wxWindow* parent, 17 | wxWindowID id, 18 | const wxPoint& pos, 19 | const wxSize& size, 20 | long style, 21 | const wxString& name); 22 | ~mdVDPStatus(); 23 | void Update(void); 24 | void Reset(void); 25 | 26 | /////////////////////////////////////////////////////////////////////////// 27 | protected: 28 | ////////// 29 | 30 | wxListCtrl *m_RegsList; 31 | int prev_Regs[24]; 32 | 33 | void OnEraseBackground(wxEraseEvent& event); 34 | //void OnDoubleClick(wxCommandEvent& event); 35 | 36 | DECLARE_EVENT_TABLE() 37 | }; 38 | 39 | /////////////////////////////////////////////////////////////////////////////// 40 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdVdpAddrCalc.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdVdpAddrCalc_H__ 2 | #define __mdVdpAddrCalc_H__ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | // 6 | #include "mdTextCtrl.h" 7 | 8 | class mdVdpAddrCalc : public wxPanel 9 | { 10 | /////////////////////////////////////////////////////////////////////////// 11 | public: 12 | /////// 13 | mdVdpAddrCalc(wxWindow* parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL, const wxString& name = "panel"); 14 | virtual ~mdVdpAddrCalc(); 15 | 16 | /////////////////////////////////////////////////////////////////////////// 17 | private: 18 | //////// 19 | wxComboBox *m_CmbCode; 20 | 21 | wxStaticText *m_Comment; 22 | mdTextCtrl *m_Address; 23 | mdTextCtrl *m_Value; 24 | bool m_UpdateOther; 25 | 26 | /*wxCheckListBox *m_CheckList; 27 | wxStaticText *m_Value; 28 | wxStaticText *m_Comment; 29 | mdTextCtrl *m_NewValue; 30 | */ 31 | DECLARE_EVENT_TABLE() 32 | 33 | void OnCombo( wxCommandEvent &event ); 34 | 35 | void OnAddressChange( wxCommandEvent &event ); 36 | void OnValueChange( wxCommandEvent &event ); 37 | 38 | void UpdateValue(); 39 | void UpdateAddress(); 40 | 41 | 42 | }; 43 | 44 | #endif 45 | /////////////////////////////////////////////////////////////////////////////// 46 | -------------------------------------------------------------------------------- /mdstudio/include/mdVdpViewer.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdVdpViewer_H__ 2 | #define __mdVdpViewer_H__ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | // 6 | #include "mdVdpRegInfo.h" 7 | #include "mdTextCtrl.h" 8 | 9 | class mdVdpViewer : public wxPanel 10 | { 11 | /////////////////////////////////////////////////////////////////////////// 12 | public: 13 | /////// 14 | mdVdpViewer(wxWindow* parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL, const wxString& name = "panel"); 15 | virtual ~mdVdpViewer(); 16 | 17 | /////////////////////////////////////////////////////////////////////////// 18 | private: 19 | //////// 20 | wxComboBox *m_CmbIO; 21 | wxCheckListBox *m_CheckList; 22 | wxStaticText *m_Value; 23 | wxStaticText *m_Comment; 24 | mdTextCtrl *m_NewValue; 25 | 26 | DECLARE_EVENT_TABLE() 27 | 28 | void OnCombo( wxCommandEvent &event ); 29 | void OnCheck( wxCommandEvent &event ); 30 | void OnUpdate( wxCommandEvent &event ); 31 | 32 | void DisplayDetails(void); 33 | void UpdateValue(); 34 | void SetValue(int idx,unsigned char value); 35 | void DisplayRegister(int idx); 36 | 37 | // regs 38 | VDPRegInfo* m_CurrentReg; 39 | VDPReg0 m_R0; 40 | VDPReg1 m_R1; 41 | VDPReg2 m_R2; 42 | VDPReg3 m_R3; 43 | VDPReg4 m_R4; 44 | VDPReg5 m_R5; 45 | VDPReg7 m_R7; 46 | VDPReg10 m_R10; 47 | VDPReg11 m_R11; 48 | VDPReg12 m_R12; 49 | VDPReg13 m_R13; 50 | VDPReg15 m_R15; 51 | VDPReg16 m_R16; 52 | VDPReg17 m_R17; 53 | VDPReg18 m_R18; 54 | VDPReg19 m_R19; 55 | VDPReg20 m_R20; 56 | VDPReg21 m_R21; 57 | VDPReg22 m_R22; 58 | VDPReg23 m_R23; 59 | }; 60 | 61 | #endif 62 | /////////////////////////////////////////////////////////////////////////////// 63 | -------------------------------------------------------------------------------- /mdstudio/include/mdVideoAdapter.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // mdVideoAdapter 3 | // 4 | // 5 | // 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | #ifndef __mdVideoAdapter_H__ 9 | #define __mdVideoAdapter_H__ 10 | 11 | /////////////////////////////////////////////////////////////////////////////// 12 | // Include 13 | 14 | #define INITGUID 15 | #define DIRECTDRAW_VERSION 0x0700 16 | #include 17 | 18 | #define RGB565(r, g, b)((r >> 3)<< 11)|((g>>2)<<5)|((b>>3)<<0) 19 | #define RGB888(r, g, b)(r<<16)|(g<<8)|b; 20 | 21 | /////////////////////////////////////////////////////////////////////////////// 22 | // Class definition 23 | /////////////////////////////////////////////////////////////////////////////// 24 | 25 | class mdVideoAdapter 26 | { 27 | /////////////////////////////////////////////////////////////////////////// 28 | public: 29 | /////// 30 | 31 | LPDIRECTDRAW7 GetDirectDraw(void){return m_DD;} 32 | LPDIRECTDRAWSURFACE7 GetFrontSurface(void ){ return m_FrontSurface;} 33 | LPDIRECTDRAWSURFACE7 GetBackSurface(void){ return m_BackSurface;} 34 | DDSCAPS2* GetDDSCaps(void){ return &m_DDSCaps; } 35 | DDSURFACEDESC2* GetDDSD(void){ return &m_DDSD;} 36 | 37 | mdVideoAdapter(HWND hwnd,bool isfullscreen); 38 | ~mdVideoAdapter(); 39 | 40 | int InitVideo(bool isfullscreen); 41 | int InitWindowed(void); 42 | int SetClipper(HWND hwnd); 43 | int ClearFrontBuffer(int color); 44 | 45 | int EncodeColor(unsigned char red,unsigned char green,unsigned char blue); 46 | void Alert(HRESULT val); 47 | 48 | int m_BitsPerPixel; 49 | int m_BytesPerPixel; 50 | 51 | /////////////////////////////////////////////////////////////////////////// 52 | protected: 53 | ////////// 54 | 55 | HWND m_Hwnd; 56 | LPDIRECTDRAW7 m_DD; 57 | LPDIRECTDRAWCLIPPER m_Clipper; 58 | LPDIRECTDRAWSURFACE7 m_FrontSurface; 59 | LPDIRECTDRAWSURFACE7 m_BackSurface; 60 | DDSCAPS2 m_DDSCaps; 61 | DDSURFACEDESC2 m_DDSD; 62 | 63 | 64 | }; 65 | 66 | /////////////////////////////////////////////////////////////////////////////// 67 | 68 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdVideoPanel.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdVideoPanel_H__ 2 | #define __mdVideoPanel_H__ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | // Class definition 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | class mdDibBitmap; 9 | class mdScreen; 10 | 11 | class mdVideoPanel: public wxPanel 12 | { 13 | /////////////////////////////////////////////////////////////////////////// 14 | public: 15 | /////// 16 | 17 | mdVideoPanel( wxWindow* parent, 18 | wxWindowID id, 19 | const wxPoint& pos, 20 | const wxSize& size, 21 | long style, 22 | const wxString& name); 23 | ~mdVideoPanel(); 24 | 25 | void SetBitmap(mdDibBitmap *bmp); 26 | 27 | /////////////////////////////////////////////////////////////////////////// 28 | protected: 29 | ////////// 30 | 31 | mdScreen *m_Screen; 32 | 33 | DECLARE_EVENT_TABLE() 34 | }; 35 | 36 | /////////////////////////////////////////////////////////////////////////////// 37 | #endif -------------------------------------------------------------------------------- /mdstudio/include/mdVideoSurface.h: -------------------------------------------------------------------------------- 1 | #ifndef __mdVIDEOSURFACE_H__ 2 | #define __mdVIDEOSURFACE_H__ 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | // Include 6 | 7 | #include 8 | 9 | /////////////////////////////////////////////////////////////////////////////// 10 | // class definition 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | class mdVideoAdapter; 14 | 15 | class mdVideoSurface 16 | { 17 | /////////////////////////////////////////////////////////////////////////// 18 | public: 19 | /////// 20 | 21 | mdVideoSurface(mdVideoAdapter *video,int width,int heigh,bool usevideomem); 22 | ~mdVideoSurface(void); 23 | 24 | unsigned char* Lock(void); 25 | void Unlock(void); 26 | 27 | int Clear(int color=0); 28 | int Clear(int red,int green,int blue); 29 | int Clear(int color,RECT *rcSrc); 30 | int EncodeColor(unsigned char red,unsigned char green,unsigned char blue); 31 | 32 | int Draw(RECT* DstRc,RECT* SrcRc); 33 | int Draw(int dst_x,int dst_y,mdVideoSurface* src,RECT* SrcRc); 34 | int Draw(RECT* DstRc,mdVideoSurface* src,RECT* SrcRc); 35 | int DrawWithColorKey(RECT* DstRc,mdVideoSurface* src,RECT* SrcRc); 36 | int DrawWithColorKey(RECT* DstRc,RECT* SrcRc); 37 | int CopyRect(RECT* DstRc,RECT* SrcRc); 38 | 39 | int GetBytesPerPixel(void){ return m_BytesPerPixel;} 40 | int GetBitsPerPixel(void){ return m_BitsPerPixel;} 41 | int GetPitch(void){ return m_Pitch;} 42 | int GetWidth(void){ return m_Width;} 43 | int GetHeight(void){return m_Height;} 44 | 45 | mdVideoAdapter* GetVideoAdapter(void){ return m_Video;} 46 | LPDIRECTDRAWSURFACE7 GetSurface(void){ return m_Surface;} 47 | 48 | void SetColorKey(unsigned char red,unsigned char green,unsigned char blue); 49 | 50 | void SetClipper(HWND hwnd){ m_Video->SetClipper(hwnd);} 51 | 52 | /////////////////////////////////////////////////////////////////////////// 53 | protected: 54 | ////////// 55 | 56 | LPDIRECTDRAWSURFACE7 m_Surface; 57 | mdVideoAdapter *m_Video; 58 | 59 | int m_Width; 60 | int m_Height; 61 | int m_Pitch; 62 | bool m_UseVideoMem; 63 | int m_BitsPerPixel; 64 | int m_BytesPerPixel; 65 | int m_SurfaceSize; 66 | 67 | int Create(int width,int height,bool usevideomem); 68 | }; 69 | 70 | /////////////////////////////////////////////////////////////////////////////// 71 | 72 | #endif -------------------------------------------------------------------------------- /mdstudio/mdstudio.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "mdstudio"=.\mdstudio.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /mdstudio/plugins/genesisplus.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pascalorama/megadrive-studio/8289e8ce63f6c4584f57ec6afc27f0361809ba0e/mdstudio/plugins/genesisplus.dll -------------------------------------------------------------------------------- /mdstudio/plugins/out_bmp/out_bmp.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // Output bmp plugins for mdtt 3 | // 4 | // 5 | // 6 | // 7 | /////////////////////////////////////////////////////////////////////////////// 8 | 9 | /////////////////////////////////////////////////////////////////////////////// 10 | // Includes 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include "../../mdttSDK.h" 19 | 20 | /////////////////////////////////////////////////////////////////////////////// 21 | // Header 22 | 23 | /////////////////////////////////////////////////////////////////////////////// 24 | // Local variables 25 | 26 | RGBQUAD gRgbSquad[256]; 27 | BITMAPFILEHEADER gFileHeader; 28 | BITMAPINFOHEADER gInfoHeader; 29 | 30 | /////////////////////////////////////////////////////////////////////////////// 31 | // Get the description of the plugins 32 | 33 | DLLEXPORT char* GetDescription(void) 34 | { 35 | return "Bmp Output"; 36 | } 37 | 38 | /////////////////////////////////////////////////////////////////////////////// 39 | // Get the author name 40 | 41 | DLLEXPORT char* GetAuthor(void) 42 | { 43 | return "Spoutnick Team"; 44 | } 45 | 46 | /////////////////////////////////////////////////////////////////////////////// 47 | // Get author contact info 48 | 49 | DLLEXPORT char* GetContactInfo(void) 50 | { 51 | return "www.spoutnickteam.com"; 52 | } 53 | 54 | /////////////////////////////////////////////////////////////////////////////// 55 | // Get build version 56 | 57 | DLLEXPORT char* GetBuildVersion(void) 58 | { 59 | return "1.0"; 60 | } 61 | 62 | /////////////////////////////////////////////////////////////////////////////// 63 | // Get id of the plugins (should be unique!) 64 | 65 | DLLEXPORT char* GetID(void) 66 | { 67 | return"bmp"; 68 | } 69 | 70 | /////////////////////////////////////////////////////////////////////////////// 71 | // file extension 72 | 73 | DLLEXPORT char* GetExt(void) 74 | { 75 | return"bmp"; 76 | } 77 | 78 | /////////////////////////////////////////////////////////////////////////////// 79 | // define the type of ouput 80 | 81 | DLLEXPORT int GetOutputType(void) 82 | { 83 | return tgOutputType_Picture; 84 | } 85 | 86 | /////////////////////////////////////////////////////////////////////////////// 87 | // Output the data 88 | 89 | DLLEXPORT int OutputPicture(const char *filename,tgPictureInfo *info,uint8* pixels,tgColor *pal) 90 | { 91 | 92 | FILE *fp; 93 | int size=0; 94 | int off=0; 95 | 96 | gInfoHeader.biWidth=info->Width; 97 | gInfoHeader.biHeight=info->Height; 98 | gInfoHeader.biBitCount=8; 99 | 100 | fp=fopen(filename,"wb"); 101 | if(!fp) 102 | return tgERR_SAVINGFILE; 103 | 104 | off=(sizeof(RGBQUAD)*256)+sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER); 105 | size=(gInfoHeader.biWidth*abs(gInfoHeader.biHeight)*(gInfoHeader.biBitCount>>3)); 106 | 107 | // init headers 108 | gFileHeader.bfType=19778; 109 | gFileHeader.bfSize=size+off; 110 | gFileHeader.bfReserved1=0; 111 | gFileHeader.bfReserved2=0; 112 | gFileHeader.bfOffBits=off; 113 | 114 | gInfoHeader.biSize=40; 115 | gInfoHeader.biPlanes=1; 116 | gInfoHeader.biCompression=0; 117 | gInfoHeader.biSizeImage=0; 118 | gInfoHeader.biXPelsPerMeter=0; 119 | gInfoHeader.biYPelsPerMeter=0; 120 | gInfoHeader.biClrUsed=0; 121 | gInfoHeader.biClrImportant=0; 122 | 123 | fwrite(&gFileHeader,sizeof(gFileHeader),1,fp); 124 | fwrite(&gInfoHeader,sizeof(gInfoHeader),1,fp); 125 | 126 | for(int i=0;i<256;i++) 127 | { gRgbSquad[i].rgbBlue=pal[i].Blue; 128 | gRgbSquad[i].rgbRed=pal[i].Red; 129 | gRgbSquad[i].rgbGreen=pal[i].Green; 130 | } 131 | 132 | 133 | if(gInfoHeader.biBitCount==8) 134 | { fwrite(&gRgbSquad,sizeof(RGBQUAD)*256,1,fp); 135 | } 136 | 137 | // flip 138 | if(gInfoHeader.biHeight>0) 139 | { 140 | int row_pitch=gInfoHeader.biWidth * (gInfoHeader.biBitCount>>3); 141 | for(int i=gInfoHeader.biHeight-1;i>=0;i--) 142 | { fwrite(&pixels[row_pitch*i],row_pitch,1,fp); } 143 | 144 | } 145 | else 146 | { fwrite(pixels,size,1,fp); } 147 | 148 | fclose(fp); 149 | 150 | return tgOK; 151 | } 152 | 153 | -------------------------------------------------------------------------------- /mdstudio/plugins/out_bmp/out_bmp.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="out_bmp" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 6 | 7 | CFG=out_bmp - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "out_bmp.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "out_bmp.mak" CFG="out_bmp - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "out_bmp - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") 21 | !MESSAGE "out_bmp - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | MTL=midl.exe 30 | RSC=rc.exe 31 | 32 | !IF "$(CFG)" == "out_bmp - Win32 Release" 33 | 34 | # PROP BASE Use_MFC 0 35 | # PROP BASE Use_Debug_Libraries 0 36 | # PROP BASE Output_Dir "Release" 37 | # PROP BASE Intermediate_Dir "Release" 38 | # PROP BASE Target_Dir "" 39 | # PROP Use_MFC 0 40 | # PROP Use_Debug_Libraries 0 41 | # PROP Output_Dir "Release" 42 | # PROP Intermediate_Dir "Release" 43 | # PROP Ignore_Export_Lib 0 44 | # PROP Target_Dir "" 45 | # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OUT_BMP_EXPORTS" /YX /FD /c 46 | # ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OUT_BMP_EXPORTS" /YX /FD /c 47 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 48 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 49 | # ADD BASE RSC /l 0x80c /d "NDEBUG" 50 | # ADD RSC /l 0x80c /d "NDEBUG" 51 | BSC32=bscmake.exe 52 | # ADD BASE BSC32 /nologo 53 | # ADD BSC32 /nologo 54 | LINK32=link.exe 55 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 56 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"../out_bmp.dll" 57 | 58 | !ELSEIF "$(CFG)" == "out_bmp - Win32 Debug" 59 | 60 | # PROP BASE Use_MFC 0 61 | # PROP BASE Use_Debug_Libraries 1 62 | # PROP BASE Output_Dir "Debug" 63 | # PROP BASE Intermediate_Dir "Debug" 64 | # PROP BASE Target_Dir "" 65 | # PROP Use_MFC 0 66 | # PROP Use_Debug_Libraries 1 67 | # PROP Output_Dir "Debug" 68 | # PROP Intermediate_Dir "Debug" 69 | # PROP Ignore_Export_Lib 0 70 | # PROP Target_Dir "" 71 | # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OUT_BMP_EXPORTS" /YX /FD /GZ /c 72 | # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OUT_BMP_EXPORTS" /YX /FD /GZ /c 73 | # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 74 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 75 | # ADD BASE RSC /l 0x80c /d "_DEBUG" 76 | # ADD RSC /l 0x80c /d "_DEBUG" 77 | BSC32=bscmake.exe 78 | # ADD BASE BSC32 /nologo 79 | # ADD BSC32 /nologo 80 | LINK32=link.exe 81 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept 82 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"../out_bmp.dll" /pdbtype:sept 83 | 84 | !ENDIF 85 | 86 | # Begin Target 87 | 88 | # Name "out_bmp - Win32 Release" 89 | # Name "out_bmp - Win32 Debug" 90 | # Begin Group "Source Files" 91 | 92 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 93 | # Begin Source File 94 | 95 | SOURCE=.\out_bmp.cpp 96 | # End Source File 97 | # End Group 98 | # Begin Group "Header Files" 99 | 100 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 101 | # End Group 102 | # Begin Group "Resource Files" 103 | 104 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 105 | # End Group 106 | # End Target 107 | # End Project 108 | -------------------------------------------------------------------------------- /mdstudio/plugins/out_pcx.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pascalorama/megadrive-studio/8289e8ce63f6c4584f57ec6afc27f0361809ba0e/mdstudio/plugins/out_pcx.dll -------------------------------------------------------------------------------- /mdstudio/plugins/out_pcx/out_pcx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pascalorama/megadrive-studio/8289e8ce63f6c4584f57ec6afc27f0361809ba0e/mdstudio/plugins/out_pcx/out_pcx.cpp -------------------------------------------------------------------------------- /mdstudio/plugins/out_pcx/out_pcx.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="out_pcx" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 6 | 7 | CFG=out_pcx - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "out_pcx.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "out_pcx.mak" CFG="out_pcx - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "out_pcx - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") 21 | !MESSAGE "out_pcx - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | MTL=midl.exe 30 | RSC=rc.exe 31 | 32 | !IF "$(CFG)" == "out_pcx - Win32 Release" 33 | 34 | # PROP BASE Use_MFC 0 35 | # PROP BASE Use_Debug_Libraries 0 36 | # PROP BASE Output_Dir "Release" 37 | # PROP BASE Intermediate_Dir "Release" 38 | # PROP BASE Target_Dir "" 39 | # PROP Use_MFC 0 40 | # PROP Use_Debug_Libraries 0 41 | # PROP Output_Dir "Release" 42 | # PROP Intermediate_Dir "Release" 43 | # PROP Ignore_Export_Lib 0 44 | # PROP Target_Dir "" 45 | # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OUT_PCX_EXPORTS" /YX /FD /c 46 | # ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OUT_PCX_EXPORTS" /YX /FD /c 47 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 48 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 49 | # ADD BASE RSC /l 0x80c /d "NDEBUG" 50 | # ADD RSC /l 0x80c /d "NDEBUG" 51 | BSC32=bscmake.exe 52 | # ADD BASE BSC32 /nologo 53 | # ADD BSC32 /nologo 54 | LINK32=link.exe 55 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 56 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"../out_pcx.dll" 57 | 58 | !ELSEIF "$(CFG)" == "out_pcx - Win32 Debug" 59 | 60 | # PROP BASE Use_MFC 0 61 | # PROP BASE Use_Debug_Libraries 1 62 | # PROP BASE Output_Dir "Debug" 63 | # PROP BASE Intermediate_Dir "Debug" 64 | # PROP BASE Target_Dir "" 65 | # PROP Use_MFC 0 66 | # PROP Use_Debug_Libraries 1 67 | # PROP Output_Dir "Debug" 68 | # PROP Intermediate_Dir "Debug" 69 | # PROP Ignore_Export_Lib 0 70 | # PROP Target_Dir "" 71 | # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OUT_PCX_EXPORTS" /YX /FD /GZ /c 72 | # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OUT_PCX_EXPORTS" /YX /FD /GZ /c 73 | # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 74 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 75 | # ADD BASE RSC /l 0x80c /d "_DEBUG" 76 | # ADD RSC /l 0x80c /d "_DEBUG" 77 | BSC32=bscmake.exe 78 | # ADD BASE BSC32 /nologo 79 | # ADD BSC32 /nologo 80 | LINK32=link.exe 81 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept 82 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"../out_pcx.dll" /pdbtype:sept 83 | 84 | !ENDIF 85 | 86 | # Begin Target 87 | 88 | # Name "out_pcx - Win32 Release" 89 | # Name "out_pcx - Win32 Debug" 90 | # Begin Group "Source Files" 91 | 92 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 93 | # Begin Source File 94 | 95 | SOURCE=.\out_pcx.cpp 96 | # End Source File 97 | # End Group 98 | # Begin Group "Header Files" 99 | 100 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 101 | # End Group 102 | # Begin Group "Resource Files" 103 | 104 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 105 | # End Group 106 | # End Target 107 | # End Project 108 | -------------------------------------------------------------------------------- /mdstudio/src/mdApp.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pascalorama/megadrive-studio/8289e8ce63f6c4584f57ec6afc27f0361809ba0e/mdstudio/src/mdApp.cpp -------------------------------------------------------------------------------- /mdstudio/src/mdBreakPoint.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // 4 | // 5 | // 6 | /////////////////////////////////////////////////////////////////////////////// 7 | // Includes 8 | #include "include/mdShared.h" 9 | #include "include/mdBreakPoint.h" 10 | 11 | 12 | mdBreakPoint::mdBreakPoint() 13 | { 14 | m_Enabled=true; 15 | m_Hits=0; 16 | } 17 | 18 | mdBreakPoint::~mdBreakPoint() 19 | {} -------------------------------------------------------------------------------- /mdstudio/src/mdCRAMPanel.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // 4 | // 5 | // 6 | /////////////////////////////////////////////////////////////////////////////// 7 | // Includes 8 | #include "include/mdShared.h" 9 | #include "include/mdEmu.h" 10 | #include "include/mdCRAMPanel.h" 11 | 12 | /////////////////////////////////////////////////////////////////////////////// 13 | // Events 14 | /////////////////////////////////////////////////////////////////////////////// 15 | 16 | BEGIN_EVENT_TABLE(mdCRAMPanel, wxPanel) 17 | EVT_PAINT(mdCRAMPanel::OnPaint) 18 | EVT_ERASE_BACKGROUND(mdCRAMPanel::OnEraseBackground) 19 | 20 | EVT_MOTION(mdCRAMPanel::OnMouseMotion) 21 | END_EVENT_TABLE() 22 | 23 | /////////////////////////////////////////////////////////////////////////////// 24 | // Constructor 25 | /////////////////////////////////////////////////////////////////////////////// 26 | 27 | mdCRAMPanel::mdCRAMPanel( wxWindow* parent, 28 | wxWindowID id, 29 | const wxPoint& pos, 30 | const wxSize& size, 31 | long style, 32 | const wxString& name) 33 | :wxPanel(parent,id,pos,size,style,name) 34 | { 35 | 36 | //m_Emu=NULL; 37 | m_CRAM=NULL; 38 | 39 | //SetToolTip(_T("CRAM Viewer")); 40 | } 41 | 42 | /////////////////////////////////////////////////////////////////////////////// 43 | // Destructor 44 | /////////////////////////////////////////////////////////////////////////////// 45 | 46 | mdCRAMPanel::~mdCRAMPanel() 47 | { 48 | } 49 | 50 | /////////////////////////////////////////////////////////////////////////////// 51 | 52 | void mdCRAMPanel::OnEraseBackground(wxEraseEvent& event) 53 | { 54 | } 55 | 56 | /////////////////////////////////////////////////////////////////////////////// 57 | // 58 | #define UNPACK_CRAM(d) ((((d)&0x1C0)>>5)|((d)&0x038)<<2|(((d)&0x007)<<9)) 59 | void mdCRAMPanel::OnPaint(wxPaintEvent& event) 60 | { 61 | wxFont fnt(10,wxDEFAULT,wxNORMAL,wxNORMAL,false,"Courier New",wxFONTENCODING_SYSTEM ); 62 | int w,h; 63 | wxPaintDC pdc(this); 64 | wxBufferedDC dc(&pdc); 65 | 66 | GetClientSize(&w,&h); 67 | dc.SetFont(fnt); 68 | dc.BeginDrawing(); 69 | 70 | // dessine le fond 71 | wxColour f(255,255,255); 72 | dc.SetPen(f); 73 | dc.SetBrush(wxBrush(f)); 74 | dc.DrawRectangle(0,0,w,h); 75 | 76 | unsigned short *pal=(unsigned short*)m_CRAM; 77 | 78 | for(int j=0;j<4;j++) 79 | { 80 | for(int i=0;i<16;i++) 81 | { 82 | unsigned short temp=UNPACK_CRAM(pal[(j*16)+i]); 83 | temp &=0x0EEE; 84 | 85 | // ----bbb-ggg-rrr- 86 | unsigned char Blue = ((temp & 0xe00)>>9) <<5; 87 | unsigned char Green = ((temp & 0xe0)>>5) <<5; 88 | unsigned char Red = ((temp & 0xe)>>1) <<5; 89 | 90 | wxColour c(Red,Green,Blue); 91 | dc.SetBrush(wxBrush(c)); 92 | 93 | dc.DrawRectangle(i*16,j*16,16,16); 94 | } 95 | 96 | } 97 | 98 | dc.EndDrawing(); 99 | } 100 | 101 | void mdCRAMPanel::UpdateCRAM() 102 | { Refresh(); 103 | } 104 | 105 | void mdCRAMPanel::SetCRAM(unsigned char* cram) 106 | { m_CRAM=cram; 107 | } 108 | 109 | void mdCRAMPanel::OnMouseMotion(wxMouseEvent& event) 110 | { 111 | int x=event.GetX(); 112 | int y=event.GetY(); 113 | 114 | if(x>0 && x<16*16 && y>0 && y<16*4) 115 | { y=y/16; 116 | x=x/16; 117 | unsigned short *pal=(unsigned short*)m_CRAM; 118 | unsigned short temp=UNPACK_CRAM(pal[(y*16)+x]); 119 | temp &=0x0EEE; 120 | 121 | // ----bbb-ggg-rrr- 122 | unsigned char Blue = ((temp & 0xe00)>>9) <<5; 123 | unsigned char Green = ((temp & 0xe0)>>5) <<5; 124 | unsigned char Red = ((temp & 0xe)>>1) <<5; 125 | wxString b; 126 | 127 | b=b.Format("Color[%d][%d]\nValue:$%.2x\nRed %.3d\nGreen %.3d\nBlue %.3d",y,x,pal[(y*16)+x],Red,Green,Blue); 128 | SetToolTip(b); 129 | } 130 | } 131 | 132 | /*void mdCRAMPanel::SetEmu(mdEmu* emu) 133 | { 134 | m_Emu=emu; 135 | }*/ 136 | 137 | -------------------------------------------------------------------------------- /mdstudio/src/mdDefaultPlugin.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // Emulator plugin definition 3 | // 4 | // 5 | // 6 | /////////////////////////////////////////////////////////////////////////////// 7 | // Includes 8 | #include "include/mdShared.h" 9 | #include "include/mdDefaultPlugin.h" 10 | 11 | /////////////////////////////////////////////////////////////////////////////// 12 | // Constructor 13 | /////////////////////////////////////////////////////////////////////////////// 14 | 15 | mdDefaultPlugin::mdDefaultPlugin(const wxString &filename) 16 | { 17 | m_Library=NULL; 18 | m_Library=new wxDynamicLibrary(filename); 19 | m_FileName = filename; 20 | 21 | m_fctGetAuthor=NULL; 22 | m_fctGetBuildVersion=NULL; 23 | m_fctGetContactInfo=NULL; 24 | m_fctGetDescription=NULL; 25 | m_fctGetExt=NULL; 26 | m_fctGetID=NULL; 27 | 28 | GetSymbols(); 29 | } 30 | 31 | /////////////////////////////////////////////////////////////////////////////// 32 | // Destructor 33 | /////////////////////////////////////////////////////////////////////////////// 34 | 35 | mdDefaultPlugin::~mdDefaultPlugin() 36 | { 37 | if(m_Library!=NULL) 38 | { if(m_Library->IsLoaded()==TRUE) 39 | m_Library->Unload(); 40 | 41 | delete(m_Library); 42 | m_Library=NULL; 43 | } 44 | } 45 | 46 | /////////////////////////////////////////////////////////////////////////////// 47 | // GetSymbols 48 | /////////////////////////////////////////////////////////////////////////////// 49 | 50 | void mdDefaultPlugin::GetSymbols(void) 51 | { 52 | if(m_Library->IsLoaded()==TRUE) 53 | { 54 | m_fctGetAuthor=(fctGetAuthor) m_Library->GetSymbol("GetAuthor"); 55 | m_fctGetBuildVersion=(fctGetBuildVersion) m_Library->GetSymbol("GetBuildVersion"); 56 | m_fctGetContactInfo=(fctGetContactInfo) m_Library->GetSymbol("GetContactInfo"); 57 | m_fctGetDescription=(fctGetDescription) m_Library->GetSymbol("GetDescription"); 58 | m_fctGetExt=(fctGetExt) m_Library->GetSymbol("GetExt"); 59 | m_fctGetID=(fctGetID) m_Library->GetSymbol("GetID"); 60 | } 61 | } 62 | 63 | /////////////////////////////////////////////////////////////////////////////// 64 | // get Author 65 | /////////////////////////////////////////////////////////////////////////////// 66 | 67 | wxString mdDefaultPlugin::GetAuthor(void) 68 | { 69 | wxString p=""; 70 | if(m_Library->IsLoaded()==TRUE) 71 | { 72 | if(m_fctGetAuthor) 73 | p.Printf("%s",m_fctGetAuthor()); 74 | } 75 | return p; 76 | } 77 | 78 | /////////////////////////////////////////////////////////////////////////////// 79 | // 80 | /////////////////////////////////////////////////////////////////////////////// 81 | 82 | wxString mdDefaultPlugin::GetDescription(void) 83 | { 84 | wxString p=""; 85 | if(m_Library->IsLoaded()==TRUE) 86 | { 87 | if(m_fctGetDescription) 88 | p.Printf("%s",m_fctGetDescription()); 89 | } 90 | return p; 91 | } 92 | 93 | /////////////////////////////////////////////////////////////////////////////// 94 | // 95 | /////////////////////////////////////////////////////////////////////////////// 96 | 97 | wxString mdDefaultPlugin::GetContactInfo(void) 98 | { 99 | wxString p=""; 100 | if(m_Library->IsLoaded()==TRUE) 101 | { 102 | if(m_fctGetContactInfo) 103 | p.Printf("%s",m_fctGetContactInfo()); 104 | } 105 | return p; 106 | } 107 | 108 | /////////////////////////////////////////////////////////////////////////////// 109 | // 110 | /////////////////////////////////////////////////////////////////////////////// 111 | 112 | wxString mdDefaultPlugin::GetBuildVersion(void) 113 | { 114 | wxString p=""; 115 | if(m_Library->IsLoaded()==TRUE) 116 | { 117 | if(m_fctGetBuildVersion) 118 | p.Printf("%s",m_fctGetBuildVersion()); 119 | } 120 | return p; 121 | } 122 | 123 | /////////////////////////////////////////////////////////////////////////////// 124 | // 125 | /////////////////////////////////////////////////////////////////////////////// 126 | 127 | wxString mdDefaultPlugin::GetID(void) 128 | { 129 | wxString p=""; 130 | if(m_Library->IsLoaded()==TRUE) 131 | { 132 | if(m_fctGetID) 133 | p.Printf("%s",m_fctGetID()); 134 | } 135 | return p; 136 | } 137 | 138 | /////////////////////////////////////////////////////////////////////////////// 139 | // 140 | /////////////////////////////////////////////////////////////////////////////// 141 | 142 | wxString mdDefaultPlugin::GetExt(void) 143 | { 144 | wxString p=""; 145 | if(m_Library->IsLoaded()==TRUE) 146 | { 147 | if(m_fctGetExt) 148 | p.Printf("%s",m_fctGetExt()); 149 | } 150 | return p; 151 | } 152 | 153 | 154 | /////////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /mdstudio/src/mdDisAsmPanel.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pascalorama/megadrive-studio/8289e8ce63f6c4584f57ec6afc27f0361809ba0e/mdstudio/src/mdDisAsmPanel.cpp -------------------------------------------------------------------------------- /mdstudio/src/mdDisasm.cpp: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | // 3 | // 4 | // 5 | // 6 | /////////////////////////////////////////////////////////////////////////////// 7 | // Includes 8 | #include "include/mdShared.h" 9 | #include "include/mdDisAsm.h" 10 | 11 | /////////////////////////////////////////////////////////////////////////////// 12 | // 13 | /////////////////////////////////////////////////////////////////////////////// 14 | 15 | mdDisasm::mdDisasm(unsigned pc,char* disasm) 16 | { 17 | m_Pc=pc; 18 | //m_Disasm=_T(disasm); 19 | } 20 | 21 | 22 | mdDisasm::~mdDisasm() 23 | {} 24 | 25 | -------------------------------------------------------------------------------- /mdstudio/src/mdFrmDumpBin.cpp: -------------------------------------------------------------------------------- 1 | #include "include/mdShared.h" 2 | #include "include/mdTextCtrl.h" 3 | #include "include/mdFrmMain.h" 4 | #include "include/mdApp.h" 5 | #include "include/mdFrmDumpBin.h" 6 | 7 | /////////////////////////////////////////////////////////////////////////////// 8 | BEGIN_EVENT_TABLE(mdFrmDumpBin, wxDialog) 9 | // EVT_CLOSE(mdFrmDumpBin::OnClose) 10 | EVT_BUTTON(200, mdFrmDumpBin::OnDump) 11 | EVT_BUTTON(250, mdFrmDumpBin::OnCancel) 12 | END_EVENT_TABLE() 13 | /////////////////////////////////////////////////////////////////////////////// 14 | mdFrmDumpBin::mdFrmDumpBin( wxWindow *frame, 15 | const wxChar *title) 16 | : wxDialog(frame, wxID_ANY, title, wxDefaultPosition, wxSize(400, 400),wxCAPTION | wxSYSTEM_MENU | wxCLOSE_BOX | wxCLIP_CHILDREN) 17 | { 18 | wxFont fntArial10(10,wxDEFAULT,wxNORMAL,wxBOLD,false,"Arial",wxFONTENCODING_SYSTEM ); 19 | this->Centre(wxBOTH); 20 | 21 | wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); 22 | 23 | // centre 24 | wxPanel *pnl=new wxPanel( this, 25 | -1, 26 | wxDefaultPosition, 27 | wxSize(0,0), 28 | wxTAB_TRAVERSAL, 29 | "Center"); 30 | 31 | // label value 32 | wxStaticText *lblAddressValue=new wxStaticText( pnl, 33 | -1, 34 | "$Base Address:", 35 | wxPoint(8,8), 36 | wxDefaultSize); 37 | lblAddressValue->SetFont(fntArial10); 38 | 39 | 40 | // Text Value: 41 | // textbox d'encodage 42 | wxArrayString inc; 43 | inc.Add(_T("a")); 44 | inc.Add(_T("b")); 45 | inc.Add(_T("c")); 46 | inc.Add(_T("d")); 47 | inc.Add(_T("e")); 48 | inc.Add(_T("f")); 49 | inc.Add(_T("A")); 50 | inc.Add(_T("B")); 51 | inc.Add(_T("C")); 52 | inc.Add(_T("D")); 53 | inc.Add(_T("E")); 54 | inc.Add(_T("F")); 55 | inc.Add(_T("0")); 56 | inc.Add(_T("1")); 57 | inc.Add(_T("2")); 58 | inc.Add(_T("3")); 59 | inc.Add(_T("4")); 60 | inc.Add(_T("5")); 61 | inc.Add(_T("6")); 62 | inc.Add(_T("7")); 63 | inc.Add(_T("8")); 64 | inc.Add(_T("9")); 65 | 66 | wxTextValidator *tx=new wxTextValidator(wxFILTER_INCLUDE_CHAR_LIST); 67 | tx->SetIncludes(inc); 68 | 69 | m_BaseAddress=new mdTextCtrl( pnl, 70 | 150, 71 | _T(""), 72 | wxPoint(120,8), 73 | wxSize(100,20), 74 | wxTE_PROCESS_ENTER | wxTE_CAPITALIZE, 75 | *tx); 76 | m_BaseAddress->SetMaxLength(8); 77 | 78 | // label value 79 | wxStaticText *lblLengthValue=new wxStaticText( pnl, 80 | -1, 81 | "$Length:", 82 | wxPoint(8,30), 83 | wxDefaultSize); 84 | lblLengthValue->SetFont(fntArial10); 85 | 86 | m_Length=new mdTextCtrl( pnl, 87 | 150, 88 | _T(""), 89 | wxPoint(120,30), 90 | wxSize(100,20), 91 | wxTE_PROCESS_ENTER | wxTE_CAPITALIZE, 92 | *tx); 93 | m_Length->SetMaxLength(8); 94 | 95 | 96 | wxButton *btn=new wxButton( pnl, 97 | 200, 98 | "Dump", 99 | wxPoint(220-60-65,60), 100 | wxSize(60,30)); 101 | 102 | wxButton *btnCancel=new wxButton( pnl, 103 | 250, 104 | "Cancel", 105 | wxPoint(220-60,60), 106 | wxSize(60,30)); 107 | 108 | sizer->Add(pnl,1,wxEXPAND ,0); 109 | 110 | // finish panel layout 111 | SetAutoLayout(TRUE); 112 | SetSizer(sizer); 113 | 114 | sizer->SetSizeHints(this); 115 | sizer->Fit(this); 116 | 117 | MaxLength=0; 118 | MaxBase=0; 119 | 120 | Show(true); 121 | } 122 | 123 | void mdFrmDumpBin::OnDump(wxCommandEvent& event) 124 | { 125 | wxString b; 126 | 127 | b=m_Length->GetValue(); 128 | if(b.Trim().Length()==0) 129 | { wxLogError("Length is mandatory"); 130 | m_Length->SetFocus(); 131 | return; 132 | } 133 | 134 | b=m_BaseAddress->GetValue(); 135 | if(b.Trim().Length()==0) 136 | { wxLogError("Base address is mandatory"); 137 | m_BaseAddress->SetFocus(); 138 | return; 139 | } 140 | 141 | long base=0; 142 | long lenght=0; 143 | 144 | b=m_Length->GetValue().Trim(); 145 | b.ToLong(&lenght,16); 146 | 147 | b=m_BaseAddress->GetValue().Trim(); 148 | b.ToLong(&base,16); 149 | 150 | if(lenght>MaxLength) 151 | { wxLogError("Length too big"); 152 | m_Length->SetFocus(); 153 | return; 154 | } 155 | 156 | if(base+lenght>MaxBase + MaxLength) 157 | { wxLogError("Error selection invalid"); 158 | return; 159 | } 160 | 161 | wxFileDialog *fd= new wxFileDialog( NULL, 162 | _T("Choose a file to dump"), 163 | "", 164 | "", 165 | "Bin (*.bin)|*.bin", 166 | wxSAVE | wxCHANGE_DIR |wxOVERWRITE_PROMPT ); 167 | if(fd->ShowModal()==wxID_OK) 168 | { *FileName=fd->GetPath(); 169 | this->EndModal(wxID_OK); 170 | } 171 | } 172 | 173 | void mdFrmDumpBin::OnCancel(wxCommandEvent& event) 174 | { 175 | this->EndModal(wxID_CANCEL); 176 | } 177 | 178 | void mdFrmDumpBin::SetOptions(wxString& filename,int default_base,int length,int max_base,int max_lenght) 179 | { 180 | FileName=&filename; 181 | wxString b; 182 | MaxLength=max_lenght; 183 | MaxBase=max_base; 184 | 185 | b=b.Format("%x",default_base); 186 | m_BaseAddress->SetValue(b); 187 | 188 | b=b.Format("%x",length); 189 | m_Length->SetValue(b); 190 | 191 | } 192 | 193 | int mdFrmDumpBin::GetBaseAddress() 194 | { 195 | long a=0; 196 | 197 | if(m_BaseAddress->GetValue().Trim().Length()>0) 198 | { m_BaseAddress->GetValue().Trim().ToLong(&a,16); } 199 | 200 | return (int)a; 201 | } 202 | 203 | int mdFrmDumpBin::GetLength() 204 | { long a=0; 205 | 206 | if(m_Length->GetValue().Trim().Length()>0) 207 | { m_Length->GetValue().Trim().ToLong(&a,16); } 208 | 209 | 210 | return a; 211 | } 212 | -------------------------------------------------------------------------------- /mdstudio/src/mdFrmGoto.cpp: -------------------------------------------------------------------------------- 1 | #include "include/mdShared.h" 2 | #include "include/mdTextCtrl.h" 3 | #include "include/mdGotoPanel.h" 4 | #include "include/mdFrmMain.h" 5 | #include "include/mdApp.h" 6 | #include "include/mdFrmGoto.h" 7 | 8 | 9 | BEGIN_EVENT_TABLE(mdFrmGoto, wxFrame) 10 | EVT_CLOSE(mdFrmGoto::OnClose) 11 | EVT_BUTTON(200, mdFrmGoto::OnGo) 12 | // EVT_BUTTON(200, mdGotoPanel::OnGo) 13 | EVT_TEXT_ENTER(150,mdFrmGoto::OnGo) 14 | END_EVENT_TABLE() 15 | 16 | mdFrmGoto::mdFrmGoto( wxFrame *frame, 17 | const wxChar *title, 18 | int x, int y, int w, int h) 19 | : wxFrame(frame, wxID_ANY, title, wxPoint(x, y), wxSize(w, h),wxSTAY_ON_TOP | wxCAPTION | wxSYSTEM_MENU | wxCLOSE_BOX | wxCLIP_CHILDREN) 20 | { 21 | this->Centre(wxBOTH); 22 | 23 | wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); 24 | 25 | 26 | // ajoute le panneau principal 27 | m_GotoPanel=new mdGotoPanel(this); 28 | sizer->Add(m_GotoPanel,1,wxEXPAND ,0); 29 | 30 | // centre 31 | wxPanel *pnl=new wxPanel( this, 32 | -1, 33 | wxDefaultPosition, 34 | wxSize(0,0), 35 | wxTAB_TRAVERSAL, 36 | "Center"); 37 | 38 | wxButton *btn=new wxButton( pnl, 39 | 200, 40 | "Go", 41 | wxPoint(110,0), 42 | wxSize(50,20)); 43 | sizer->Add(pnl,1,wxEXPAND ,0); 44 | 45 | // finish panel layout 46 | SetAutoLayout(TRUE); 47 | SetSizer(sizer); 48 | 49 | sizer->SetSizeHints(this); 50 | sizer->Fit(this); 51 | 52 | Show(true); 53 | } 54 | 55 | void mdFrmGoto::OnClose(wxCloseEvent& event) 56 | { 57 | event.Veto(); 58 | this->Hide(); 59 | } 60 | 61 | void mdFrmGoto::OnGo( wxCommandEvent &event) 62 | { 63 | unsigned long value=0; 64 | wxString v=m_GotoPanel->GetAddress(); 65 | if(v.Trim().Length()>0) 66 | { v.ToULong(&value,16); 67 | gFrmMain->GotoAddress(value); 68 | } 69 | 70 | this->Hide(); 71 | } -------------------------------------------------------------------------------- /mdstudio/src/mdFrmMain.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pascalorama/megadrive-studio/8289e8ce63f6c4584f57ec6afc27f0361809ba0e/mdstudio/src/mdFrmMain.cpp -------------------------------------------------------------------------------- /mdstudio/src/mdFrmSpyAttr.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pascalorama/megadrive-studio/8289e8ce63f6c4584f57ec6afc27f0361809ba0e/mdstudio/src/mdFrmSpyAttr.cpp -------------------------------------------------------------------------------- /mdstudio/src/mdFrmVDPAddrCalc.cpp: -------------------------------------------------------------------------------- 1 | #include "include/mdShared.h" 2 | #include "include/mdTextCtrl.h" 3 | #include "include/mdVDPAddrCalc.h" 4 | #include "include/mdFrmVDPAddrCalc.h" 5 | 6 | 7 | BEGIN_EVENT_TABLE(mdFrmVdpAddrCalc, wxFrame) 8 | EVT_CLOSE(mdFrmVdpAddrCalc::OnClose) 9 | END_EVENT_TABLE() 10 | 11 | mdFrmVdpAddrCalc::mdFrmVdpAddrCalc( wxFrame *frame, 12 | const wxChar *title, 13 | int x, int y, int w, int h) 14 | : wxFrame(frame, wxID_ANY, title, wxPoint(x, y), wxSize(w, h),wxSTAY_ON_TOP | wxMINIMIZE_BOX | wxCAPTION | wxSYSTEM_MENU | wxCLOSE_BOX | wxCLIP_CHILDREN) 15 | { 16 | this->Centre(wxBOTH); 17 | 18 | m_VdpAddrCalc=new mdVdpAddrCalc(this); 19 | 20 | Show(true); 21 | } 22 | 23 | void mdFrmVdpAddrCalc::OnClose(wxCloseEvent& event) 24 | { 25 | event.Veto(); 26 | this->Hide(); 27 | 28 | } -------------------------------------------------------------------------------- /mdstudio/src/mdFrmVdpCalc.cpp: -------------------------------------------------------------------------------- 1 | #include "include/mdShared.h" 2 | #include "include/mdTextCtrl.h" 3 | #include "include/mdVdpViewer.h" 4 | #include "include/mdFrmVdpCalc.h" 5 | 6 | 7 | BEGIN_EVENT_TABLE(mdFrmVdpCalc, wxFrame) 8 | EVT_CLOSE(mdFrmVdpCalc::OnClose) 9 | END_EVENT_TABLE() 10 | 11 | mdFrmVdpCalc::mdFrmVdpCalc( wxFrame *frame, 12 | const wxChar *title, 13 | int x, int y, int w, int h) 14 | : wxFrame(frame, wxID_ANY, title, wxPoint(x, y), wxSize(w, h),wxSTAY_ON_TOP | wxMINIMIZE_BOX | wxCAPTION | wxSYSTEM_MENU | wxCLOSE_BOX | wxCLIP_CHILDREN) 15 | { 16 | 17 | m_Viewer= new mdVdpViewer(this); 18 | 19 | 20 | this->Centre(wxBOTH); 21 | Show(true); 22 | 23 | } 24 | 25 | void mdFrmVdpCalc::OnClose(wxCloseEvent& event) 26 | { 27 | event.Veto(); 28 | this->Hide(); 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /mdstudio/src/mdGotoPanel.cpp: -------------------------------------------------------------------------------- 1 | //#include "include/mdShared.h" 2 | //#include "include/mdTextCtrl.h" 3 | //#include "include/mdGotoPanel.h" 4 | 5 | #include "include/mdShared.h" 6 | #include "include/mdTextCtrl.h" 7 | #include "include/mdFrmGoto.h" 8 | #include "include/mdGotoPanel.h" 9 | 10 | #include "include/mdfrmmain.h" 11 | #include "include/mdApp.h" 12 | 13 | /////////////////////////////////////////////////////////////////////////////// 14 | // events 15 | BEGIN_EVENT_TABLE(mdGotoPanel, wxPanel) 16 | // EVT_BUTTON(200, mdGotoPanel::OnGo) 17 | // EVT_TEXT_ENTER(150,mdFrmGoto::OnGo) 18 | END_EVENT_TABLE() 19 | 20 | /////////////////////////////////////////////////////////////////////////////// 21 | // constructor 22 | mdGotoPanel::mdGotoPanel(wxWindow* parent, 23 | wxWindowID id, 24 | const wxPoint& pos, 25 | const wxSize& size, 26 | long style, 27 | const wxString& name):wxPanel(parent,id,pos,size,style,name) 28 | { 29 | 30 | wxFont fntArial10(10,wxDEFAULT,wxNORMAL,wxBOLD,false,"Arial",wxFONTENCODING_SYSTEM ); 31 | wxBoxSizer *sizerTop = new wxBoxSizer(wxVERTICAL); 32 | 33 | // centre 34 | wxPanel *pnl=new wxPanel( this, 35 | -1, 36 | wxDefaultPosition, 37 | wxSize(0,150), 38 | wxTAB_TRAVERSAL, 39 | "Center"); 40 | 41 | // label value 42 | wxStaticText *lblHeaderValue=new wxStaticText( pnl, 43 | -1, 44 | "Address:", 45 | wxPoint(4,4), 46 | wxDefaultSize); 47 | lblHeaderValue->SetFont(fntArial10); 48 | 49 | // Text Value: 50 | // textbox d'encodage 51 | wxArrayString inc; 52 | inc.Add(_T("a")); 53 | inc.Add(_T("b")); 54 | inc.Add(_T("c")); 55 | inc.Add(_T("d")); 56 | inc.Add(_T("e")); 57 | inc.Add(_T("f")); 58 | inc.Add(_T("A")); 59 | inc.Add(_T("B")); 60 | inc.Add(_T("C")); 61 | inc.Add(_T("D")); 62 | inc.Add(_T("E")); 63 | inc.Add(_T("F")); 64 | inc.Add(_T("0")); 65 | inc.Add(_T("1")); 66 | inc.Add(_T("2")); 67 | inc.Add(_T("3")); 68 | inc.Add(_T("4")); 69 | inc.Add(_T("5")); 70 | inc.Add(_T("6")); 71 | inc.Add(_T("7")); 72 | inc.Add(_T("8")); 73 | inc.Add(_T("9")); 74 | 75 | wxTextValidator *tx=new wxTextValidator(wxFILTER_INCLUDE_CHAR_LIST); 76 | tx->SetIncludes(inc); 77 | 78 | m_Address=new mdTextCtrl( pnl, 79 | 150, 80 | _T(""), 81 | wxPoint(60,4), 82 | wxSize(100,20), 83 | wxTE_PROCESS_ENTER | wxTE_CAPITALIZE, 84 | *tx); 85 | m_Address->SetMaxLength(8); 86 | 87 | 88 | sizerTop->Add(pnl,1,wxEXPAND ,0); 89 | 90 | // finish panel layout 91 | SetAutoLayout(TRUE); 92 | SetSizer(sizerTop); 93 | 94 | sizerTop->SetSizeHints(this); 95 | sizerTop->Fit(this); 96 | 97 | m_Address->SelectAll(); 98 | } 99 | 100 | /////////////////////////////////////////////////////////////////////////////// 101 | // Destructeur 102 | mdGotoPanel::~mdGotoPanel() 103 | { 104 | 105 | } 106 | 107 | void mdGotoPanel::OnGo( wxCommandEvent &event) 108 | { 109 | unsigned long value=0; 110 | wxString v=m_Address->GetValue(); 111 | if(v.Trim().Length()>0) 112 | { v.ToULong(&value,16); 113 | gFrmMain->GotoAddress(value); 114 | } 115 | } 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /mdstudio/src/mdListLine.cpp: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | // 3 | // 4 | // 5 | // 6 | /////////////////////////////////////////////////////////////////////////////// 7 | // Includes 8 | #include "include/mdShared.h" 9 | #include "include/mdListLine.h" 10 | 11 | 12 | mdListLine::mdListLine() 13 | { 14 | pc=0; 15 | Text=_T(""); 16 | page=0; 17 | 18 | } 19 | 20 | mdListLine::~mdListLine() 21 | { 22 | } -------------------------------------------------------------------------------- /mdstudio/src/mdOutputDataPlugin.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // Emulator plugin definition 3 | // 4 | // 5 | // 6 | /////////////////////////////////////////////////////////////////////////////// 7 | // Includes 8 | #include "include/mdShared.h" 9 | #include "include/mdDefaultPlugin.h" 10 | #include "include/mdOutputDataPlugin.h" 11 | 12 | /////////////////////////////////////////////////////////////////////////////// 13 | // Constructor 14 | /////////////////////////////////////////////////////////////////////////////// 15 | 16 | mdOutputDataPlugin::mdOutputDataPlugin(const wxString &filename):mdDefaultPlugin(filename) 17 | { 18 | m_fctGetOuputType=NULL; 19 | m_fctOutputPicture=NULL; 20 | 21 | GetSymbols(); 22 | } 23 | 24 | /////////////////////////////////////////////////////////////////////////////// 25 | // GetSymbols 26 | /////////////////////////////////////////////////////////////////////////////// 27 | 28 | void mdOutputDataPlugin::GetSymbols(void) 29 | { 30 | if(m_Library->IsLoaded()==TRUE) 31 | { 32 | m_fctGetOuputType=(fctGetOutputType) m_Library->GetSymbol("GetOutputType"); 33 | m_fctOutputPicture=(fctOutputPicture) m_Library->GetSymbol("OutputPicture"); 34 | } 35 | } 36 | 37 | 38 | /////////////////////////////////////////////////////////////////////////////// 39 | // 40 | /////////////////////////////////////////////////////////////////////////////// 41 | 42 | int mdOutputDataPlugin::OutputPicture(wxString& filename,mdPictureInfo *info,unsigned char* pixels,mdColor *pal) 43 | { 44 | int ret=0; 45 | 46 | if(m_Library->IsLoaded()==TRUE) 47 | { if(m_fctOutputPicture) 48 | return m_fctOutputPicture((char*)filename.c_str(),info,pixels,pal); 49 | } 50 | return 0; 51 | 52 | } 53 | 54 | 55 | /////////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /mdstudio/src/mdPluginList.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pascalorama/megadrive-studio/8289e8ce63f6c4584f57ec6afc27f0361809ba0e/mdstudio/src/mdPluginList.cpp -------------------------------------------------------------------------------- /mdstudio/src/mdProgressStatusBar.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // 4 | // 5 | // 6 | /////////////////////////////////////////////////////////////////////////////// 7 | // Includes 8 | #include "include/mdShared.h" 9 | #include "include/mdProgressStatusBar.h" 10 | 11 | /////////////////////////////////////////////////////////////////////////////// 12 | // Events 13 | /////////////////////////////////////////////////////////////////////////////// 14 | 15 | BEGIN_EVENT_TABLE(mdProgressStatusBar, wxStatusBar) 16 | EVT_SIZE(mdProgressStatusBar::OnSize) 17 | END_EVENT_TABLE() 18 | 19 | /////////////////////////////////////////////////////////////////////////////// 20 | // Constructor 21 | /////////////////////////////////////////////////////////////////////////////// 22 | 23 | mdProgressStatusBar::mdProgressStatusBar( wxWindow *parent, 24 | const wxString &text, 25 | long maxvalue): 26 | wxStatusBar(parent, -1) 27 | { 28 | int widths[2]={200,-2}; 29 | m_Gauge=new wxGauge(this,-1,maxvalue); 30 | m_Gauge->Hide(); 31 | this->SetFieldsCount(2); 32 | this->SetStatusWidths(2, widths); 33 | this->SetStatusText(text); 34 | m_MaxValue=maxvalue; 35 | } 36 | 37 | /////////////////////////////////////////////////////////////////////////////// 38 | // Destructor 39 | /////////////////////////////////////////////////////////////////////////////// 40 | 41 | mdProgressStatusBar::~mdProgressStatusBar() 42 | { 43 | if(m_Gauge) 44 | delete(m_Gauge); 45 | } 46 | 47 | /////////////////////////////////////////////////////////////////////////////// 48 | // Force a resize 49 | /////////////////////////////////////////////////////////////////////////////// 50 | 51 | void mdProgressStatusBar::SendSizeEvent() 52 | { 53 | wxRect rect; 54 | GetFieldRect(1, rect); 55 | m_Gauge->SetSize(rect.x + 2, rect.y + 2, rect.width - 4, rect.height - 4); 56 | m_Gauge->Show(); 57 | } 58 | 59 | /////////////////////////////////////////////////////////////////////////////// 60 | // Resize Event 61 | /////////////////////////////////////////////////////////////////////////////// 62 | 63 | void mdProgressStatusBar::OnSize(wxSizeEvent& event) 64 | { 65 | SendSizeEvent(); 66 | event.Skip(); 67 | } 68 | 69 | /////////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /mdstudio/src/mdProject.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pascalorama/megadrive-studio/8289e8ce63f6c4584f57ec6afc27f0361809ba0e/mdstudio/src/mdProject.cpp -------------------------------------------------------------------------------- /mdstudio/src/mdProxy.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // Proxies functions 3 | // 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | #include "wx/wxprec.h" 7 | #ifndef WX_PRECOMP 8 | #include "wx/wx.h" 9 | #include "wx/app.h" 10 | #include "wx/frame.h" 11 | #endif 12 | 13 | /////////////////////////////////////////////////////////////////////////////// 14 | // app includes 15 | #include "include/mdEmu.h" 16 | #include "include/mdFrmMain.h" 17 | #include "include/mdDibBitmap.h" 18 | #include "include/mdShared.h" 19 | #include "include/mdApp.h" 20 | 21 | /////////////////////////////////////////////////////////////////////////////// 22 | // 23 | int CheckBreakPoint(unsigned int pc) 24 | { 25 | if(gEmu->ExecuteBreakPoint((int)pc)==1) 26 | { gEmu->m_ReachedBreakPoint=true; 27 | return 1; 28 | } 29 | return 0; 30 | } 31 | 32 | void SetBreakPoint(unsigned int pc) 33 | { 34 | gEmu->CreateBreakPoint(pc); 35 | } 36 | 37 | void LogMessage(int level,char* msg) 38 | { 39 | gFrmMain->LogMessage(level,msg); 40 | } 41 | 42 | void LogChar(char msg) 43 | { 44 | gFrmMain->LogChar(0,msg); 45 | } 46 | 47 | char* GetSymbolName(int type,unsigned int pc) 48 | { 49 | switch(type) 50 | { 51 | case 0: 52 | { return gProject->GetSymbolVariableName(pc); 53 | } break; 54 | 55 | case 1: 56 | { return gProject->GetSymbolLabelName(pc); 57 | }break; 58 | 59 | default: 60 | { return gProject->GetSymbolName(pc);}break; 61 | } 62 | 63 | return NULL; 64 | 65 | } 66 | -------------------------------------------------------------------------------- /mdstudio/src/mdRegPanel.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pascalorama/megadrive-studio/8289e8ce63f6c4584f57ec6afc27f0361809ba0e/mdstudio/src/mdRegPanel.cpp -------------------------------------------------------------------------------- /mdstudio/src/mdScreen.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // 4 | // 5 | // NOT PORTABLE I'M USING DIB 6 | /////////////////////////////////////////////////////////////////////////////// 7 | // Includes 8 | #include "include/mdShared.h" 9 | #include "include/mdDibBitmap.h" 10 | #include "include/mdVideoAdapter.h" 11 | #include "include/mdVideoSurface.h" 12 | 13 | #include "include/mdFrmMain.h" 14 | #include "include/mdApp.h" 15 | 16 | #include "include/mdScreen.h" 17 | 18 | /////////////////////////////////////////////////////////////////////////////// 19 | // Events 20 | /////////////////////////////////////////////////////////////////////////////// 21 | 22 | BEGIN_EVENT_TABLE(mdScreen, wxPanel) 23 | EVT_ERASE_BACKGROUND(mdScreen::OnEraseBackground) 24 | EVT_PAINT(mdScreen::OnPaint) 25 | 26 | END_EVENT_TABLE() 27 | 28 | /////////////////////////////////////////////////////////////////////////////// 29 | // Constructor 30 | /////////////////////////////////////////////////////////////////////////////// 31 | 32 | mdScreen::mdScreen( wxWindow* parent, 33 | wxWindowID id, 34 | const wxPoint& pos, 35 | const wxSize& size, 36 | long style, 37 | const wxString& name) 38 | :wxPanel(parent,id,pos,size,style,name) 39 | { 40 | 41 | m_Bitmap=NULL; 42 | m_Surface=NULL; 43 | 44 | m_Zoom=1; 45 | } 46 | 47 | /////////////////////////////////////////////////////////////////////////////// 48 | // Destructor 49 | /////////////////////////////////////////////////////////////////////////////// 50 | 51 | mdScreen::~mdScreen() 52 | { 53 | m_Bitmap=NULL; 54 | 55 | delete(m_Surface); 56 | } 57 | 58 | /////////////////////////////////////////////////////////////////////////////// 59 | // Override to prevent bg flickering 60 | /////////////////////////////////////////////////////////////////////////////// 61 | 62 | void mdScreen::OnEraseBackground(wxEraseEvent& event) 63 | { 64 | } 65 | 66 | /////////////////////////////////////////////////////////////////////////////// 67 | // Override to prevent bg flickering 68 | /////////////////////////////////////////////////////////////////////////////// 69 | 70 | void mdScreen::OnPaint(wxPaintEvent& event) 71 | { 72 | wxPaintDC dc(this); 73 | 74 | if(m_Bitmap!=NULL) 75 | { 76 | RECT rc; 77 | RECT src; 78 | 79 | int x=0,y=0,w=0,h=0; 80 | GetClientSize(&w,&h); 81 | ClientToScreen(&x,&y); 82 | 83 | rc.top=y; 84 | rc.left=x; 85 | rc.right=rc.left+(w ); 86 | rc.bottom=rc.top+(h ); 87 | 88 | src.left=0; 89 | src.right=320 ; 90 | src.bottom=240; 91 | src.top=0; 92 | 93 | m_Surface->SetClipper((HWND) GetHandle()); 94 | 95 | if(m_Surface->GetVideoAdapter()->m_BytesPerPixel==2) 96 | { 97 | unsigned short *b=(unsigned short*) m_Surface->Lock(); 98 | unsigned short *c=(unsigned short*) m_Bitmap->Data; 99 | unsigned short *ptr_dest=b; 100 | unsigned short *ptr_src=&c[32]; 101 | 102 | for(int y=0;y<240;y++) 103 | { ptr_dest=&b[y*320]; 104 | ptr_src=&c[32+(1024*y)]; 105 | for(int x=0;x<320;x++) 106 | { *ptr_dest++=*ptr_src++; 107 | } 108 | } 109 | }else if(m_Surface->GetVideoAdapter()->m_BytesPerPixel==4) 110 | { 111 | unsigned int *b=(unsigned int*) m_Surface->Lock(); 112 | unsigned int *c=(unsigned int*) m_Bitmap->Data; 113 | 114 | for(int y=0;y<240;y++) 115 | { for(int x=0;x<320;x++) 116 | { b[(y*320)+x]=c[32+(1024*y)+x]; 117 | } 118 | } 119 | } 120 | m_Surface->Unlock(); 121 | m_Surface->Draw(&rc,&src); 122 | } 123 | } 124 | 125 | void mdScreen::SetBitmap(mdDibBitmap *bmp) 126 | { m_Bitmap=bmp; 127 | if(m_Surface==NULL) 128 | { mdVideoAdapter *v=gFrmMain->m_VideoAdapter; 129 | m_Surface=new mdVideoSurface(v,320*m_Zoom,240*m_Zoom,false); 130 | m_Surface->GetVideoAdapter()->ClearFrontBuffer(0xff00); 131 | m_Surface->Clear(255,0,255); 132 | } 133 | } 134 | 135 | /////////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /mdstudio/src/mdSection.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // 4 | // 5 | // 6 | /////////////////////////////////////////////////////////////////////////////// 7 | // Includes 8 | #include "include/mdShared.h" 9 | #include "include/mdSection.h" 10 | 11 | mdSection::mdSection() 12 | { Base=0; 13 | Name=_T(""); 14 | } 15 | 16 | mdSection::~mdSection() 17 | { 18 | } 19 | -------------------------------------------------------------------------------- /mdstudio/src/mdSpiesPanel.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pascalorama/megadrive-studio/8289e8ce63f6c4584f57ec6afc27f0361809ba0e/mdstudio/src/mdSpiesPanel.cpp -------------------------------------------------------------------------------- /mdstudio/src/mdSpy.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // 4 | // 5 | // 6 | /////////////////////////////////////////////////////////////////////////////// 7 | // Includes 8 | #include "include/mdShared.h" 9 | #include "include/mdSymbol.h" 10 | #include "include/mdFrmMain.h" 11 | #include "include/mdApp.h" 12 | 13 | #include "include/mdSpy.h" 14 | 15 | 16 | mdSpy::mdSpy() 17 | { 18 | m_Address=0; 19 | m_Value=0; 20 | m_Length=1; 21 | m_Name=_T(""); 22 | 23 | m_ListIndex=-1; 24 | m_ArraySize=1; 25 | m_IsFromArray=false; 26 | m_DisplayHexa=false; 27 | } 28 | 29 | mdSpy::~mdSpy() 30 | { 31 | } 32 | 33 | void mdSpy::SetAddress(int adr,bool UpdateSymbols) 34 | { 35 | m_Address=adr; 36 | 37 | // remplace le symbol si existe ou cree 38 | if(UpdateSymbols==true) 39 | m_Symbol=gProject->InsertSymbol(NULL,m_Name,adr,0,true); 40 | 41 | } 42 | 43 | void mdSpy::SetName(wxString &name) 44 | { 45 | m_Name=name; 46 | } 47 | 48 | wxString& mdSpy::GetName(void) 49 | { return m_Name; 50 | } 51 | 52 | int mdSpy::GetAddress(void) 53 | { return m_Address; 54 | } -------------------------------------------------------------------------------- /mdstudio/src/mdSymbol.cpp: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | // 3 | // 4 | // 5 | // 6 | /////////////////////////////////////////////////////////////////////////////// 7 | // Includes 8 | #include "include/mdShared.h" 9 | #include "include/mdSection.h" 10 | #include "include/mdSymbol.h" 11 | 12 | 13 | mdSymbol::mdSymbol() 14 | { Section=NULL; 15 | Address=0; 16 | Name=_T(""); 17 | Displacement=0; 18 | UserCreated=true; 19 | } 20 | 21 | mdSymbol::~mdSymbol() 22 | { 23 | } -------------------------------------------------------------------------------- /mdstudio/src/mdSymbolPair.cpp: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | // 3 | // 4 | // 5 | // 6 | /////////////////////////////////////////////////////////////////////////////// 7 | // Includes 8 | #include "include/mdShared.h" 9 | #include "include/mdSymbol.h" 10 | #include "include/mdSymbolPair.h" 11 | 12 | mdSymbolPair::mdSymbolPair() 13 | { 14 | Label=NULL; 15 | Variable=NULL; 16 | } 17 | 18 | mdSymbolPair::~mdSymbolPair() 19 | { 20 | } -------------------------------------------------------------------------------- /mdstudio/src/mdSymbolsPanel.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pascalorama/megadrive-studio/8289e8ce63f6c4584f57ec6afc27f0361809ba0e/mdstudio/src/mdSymbolsPanel.cpp -------------------------------------------------------------------------------- /mdstudio/src/mdTextCtrl.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // 4 | /////////////////////////////////////////////////////////////////////////////// 5 | // app includes 6 | #include "include/mdShared.h" 7 | #include "include/mdTextCtrl.h" 8 | 9 | BEGIN_EVENT_TABLE(mdTextCtrl, wxTextCtrl) 10 | EVT_CONTEXT_MENU(mdTextCtrl::OnContextMenu) 11 | EVT_KEY_DOWN(mdTextCtrl::OnKeydown) 12 | END_EVENT_TABLE() 13 | 14 | /////////////////////////////////////////////////////////////////////////////// 15 | // Constructor 16 | 17 | mdTextCtrl::mdTextCtrl(wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style,const wxValidator& validator, const wxString& name) 18 | :wxTextCtrl(parent,id,value,pos,size,style,validator,name) 19 | { 20 | 21 | } 22 | 23 | 24 | 25 | void mdTextCtrl::OnContextMenu(wxContextMenuEvent& event) 26 | { 27 | 28 | } 29 | 30 | 31 | 32 | void mdTextCtrl::OnKeydown(wxKeyEvent& event) 33 | { 34 | if(event.m_controlDown==TRUE && event.m_keyCode==86 ) 35 | {} 36 | else 37 | event.Skip(); 38 | } -------------------------------------------------------------------------------- /mdstudio/src/mdTileViewerPanel.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // mdTileViewerPanel 3 | // 4 | // 5 | // 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | /////////////////////////////////////////////////////////////////////////////// 9 | // Includes 10 | #include "mdShared.h" 11 | #include "mdVideoAdapter.h" 12 | #include "mdVideoSurface.h" 13 | #include "mdTileViewerPanel.h" 14 | 15 | /////////////////////////////////////////////////////////////////////////////// 16 | // Events 17 | 18 | BEGIN_EVENT_TABLE(mdTileViewerPanel, wxWindow) 19 | 20 | EVT_ERASE_BACKGROUND(mdTileViewerPanel::OnEraseBackground) 21 | EVT_PAINT(mdTileViewerPanel::OnPaint) 22 | 23 | END_EVENT_TABLE() 24 | 25 | mdTileViewerPanel::mdTileViewerPanel( wxWindow* parent, 26 | wxWindowID id, 27 | const wxPoint& pos, 28 | const wxSize& size, 29 | long style, 30 | const wxString& name) 31 | :wxWindow(parent,id,pos,size,style,name) 32 | { 33 | m_Surface=NULL; 34 | } 35 | 36 | /////////////////////////////////////////////////////////////////////////////// 37 | // Desctructor 38 | 39 | mdTileViewerPanel::~mdTileViewerPanel() 40 | { delete(m_Surface); 41 | } 42 | 43 | /////////////////////////////////////////////////////////////////////////////// 44 | // Override to prevent bg flickering 45 | /////////////////////////////////////////////////////////////////////////////// 46 | 47 | void mdTileViewerPanel::OnEraseBackground(wxEraseEvent& event) 48 | { 49 | } 50 | 51 | /////////////////////////////////////////////////////////////////////////////// 52 | // Override to prevent bg flickering 53 | /////////////////////////////////////////////////////////////////////////////// 54 | 55 | void mdTileViewerPanel::OnPaint(wxPaintEvent& event) 56 | { 57 | wxPaintDC dc(this); 58 | } -------------------------------------------------------------------------------- /mdstudio/src/mdVDPStatusPanel.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pascalorama/megadrive-studio/8289e8ce63f6c4584f57ec6afc27f0361809ba0e/mdstudio/src/mdVDPStatusPanel.cpp -------------------------------------------------------------------------------- /mdstudio/src/mdVideoPanel.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // 4 | // 5 | // NOT PORTABLE I'M USING DIB 6 | /////////////////////////////////////////////////////////////////////////////// 7 | // Includes 8 | #include "include/mdShared.h" 9 | #include "include/mdScreen.h" 10 | #include "include/mdVideoPanel.h" 11 | 12 | /////////////////////////////////////////////////////////////////////////////// 13 | // Events 14 | /////////////////////////////////////////////////////////////////////////////// 15 | 16 | BEGIN_EVENT_TABLE(mdVideoPanel, wxPanel) 17 | 18 | END_EVENT_TABLE() 19 | 20 | /////////////////////////////////////////////////////////////////////////////// 21 | // Constructor 22 | /////////////////////////////////////////////////////////////////////////////// 23 | 24 | mdVideoPanel::mdVideoPanel( wxWindow* parent, 25 | wxWindowID id, 26 | const wxPoint& pos, 27 | const wxSize& size, 28 | long style, 29 | const wxString& name) 30 | :wxPanel(parent,id,pos,size,style,name) 31 | { 32 | m_Screen=new mdScreen( this, 33 | -1, 34 | wxDefaultPosition, 35 | wxSize(320,240), 36 | wxTAB_TRAVERSAL, 37 | "Center"); 38 | 39 | } 40 | 41 | /////////////////////////////////////////////////////////////////////////////// 42 | // Destructor 43 | /////////////////////////////////////////////////////////////////////////////// 44 | 45 | mdVideoPanel::~mdVideoPanel() 46 | { 47 | } 48 | 49 | void mdVideoPanel::SetBitmap(mdDibBitmap *bmp) 50 | { 51 | m_Screen->SetBitmap(bmp); 52 | } 53 | 54 | /////////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /mdstudio/vc_mswd/mdstudio.idb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pascalorama/megadrive-studio/8289e8ce63f6c4584f57ec6afc27f0361809ba0e/mdstudio/vc_mswd/mdstudio.idb --------------------------------------------------------------------------------